Skip to content

Instantly share code, notes, and snippets.

@tjstein
Created November 17, 2009 04:23
Show Gist options
  • Save tjstein/236639 to your computer and use it in GitHub Desktop.
Save tjstein/236639 to your computer and use it in GitHub Desktop.
gs-backup.sh
#!/bin/bash
# Tar shit up:
today=$(date '+%d_%m_%y')
echo "* Performing domain backup..."
tar czf /var/backups/constantshift.com_"$today".tar.gz -C / var/www/constantshift.com
echo "* Backed up..."
# Remove shit older than 7 days:
MaxFileAge=7
find /var/backups/ -name '*.gz' -type f -mtime +$MaxFileAge -exec rm -f {} \;
# Rsync shit to the grid:
echo "* Rsyncing to remote host..."
rsync --quiet -az -e "ssh -i /root/.ssh/id_rsa" "/var/backups/constantshift.com_"$today".tar.gz" s58608.gridserver.com@s58608.gridserver.com:/home/58608/data/backup/
echo "* Rsync finished!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment