Skip to content

Instantly share code, notes, and snippets.

@cearls
Created September 27, 2011 15:10
Show Gist options
  • Save cearls/1245316 to your computer and use it in GitHub Desktop.
Save cearls/1245316 to your computer and use it in GitHub Desktop.
Rackspace Cloud Site backup script
#!/bin/bash
export ACCOUNT_ROOT="account root"
export WEB_ROOT="${ACCOUNT_ROOT}/web/content"
export DB_HOST="db host"
export DB_USER="db user"
export DB_PASSWORD="db password"
export DB_NAME="db name"
echo "Rotating backups..."
rm -rf $WEB_ROOT/backup/02
mv $WEB_ROOT/backup/01 $WEB_ROOT/backup/02
mkdir $WEB_ROOT/backup/01
echo "... done rotating backups."
echo "Starting database backup..."
mysqldump --host=$DB_HOST --user=$DB_USER --password=$DB_PASSWORD --all-databases | bzip2 > $WEB_ROOT/backup/01/mysql-`date +%Y-%m-%d`.bz2
echo "... database backup complete."
echo "Starting file system backup..."
tar czf $WEB_ROOT/backup/01/web_backup.tgz $WEB_ROOT --exclude $WEB_ROOT/backup
echo "... file system backup complete."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment