Skip to content

Instantly share code, notes, and snippets.

@dtateii
Last active August 29, 2015 14:01
Show Gist options
  • Save dtateii/7f8778eb80176488011d to your computer and use it in GitHub Desktop.
Save dtateii/7f8778eb80176488011d to your computer and use it in GitHub Desktop.
Script cron can run to archive db and files on a Rackspace Cloud Site
#!/bin/sh
# http://www.rackspace.com/knowledge_center/article/how-to-use-cron-to-backup-cloudsites-to-cloudfiles
# Set information specific to your site.
domainroot="www.domain.com"
db_host="mysqlnn-nnn.abcd.stabletransit.com"
db_user="nnnnnn_abcd_dbu"
db_password="**********"
db_name="nnnnnn_abcdefg"
# Set the date and name for the backup files.
date=`date '+%F_%H:%M'`
webarchive="web.tar.gz"
# Make directory for backup.
mkdir -p $domainroot/archive/$date
# Dump the mysql database.
mysqldump -h $db_host -u $db_user --password="$db_password" $db_name > $domainroot/archive/$date/db.sql
# Backup Site files.
tar -zcf $domainroot/archive/$date/$webarchive $domainroot/web/content/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment