Backing up sites on Dreamhost

I recently FUBAR’d a Concrete5 site during an upgrade process, and realized that the last time I nuke’n’paved my home computer, I also wiped all of my backups, and the backup script.


So I recently put together the following shell script, living in my user directory on Dreamhost, to backup each site as a cronjob. I’m keeping 7 days on there for now, and will set up my home computer to download (and keep) even older archives.

This is a first-pass script; eventually, I may make it more flexible so that it can run from a list of sites & databases. Right now, you need to create a new copy of the script (and a new cronjob) for each site.

UPDATE 2014-04-02: I have moved from Dreamhost to DigitalOcean (private VPS) and the script is now substantially rewritten. I have yet to publish the revised version, but it is much more modular and flexible now.

_now=$(date +"%Y_%m_%d")
_homePath="/home/[dreamhost ftp username]"
_sqlHost="[SQL host]"
_sqlDb="[SQL Database]"
_sqlUser="[SQL Username]"
_sqlPass="[SQL Password]"
echo "Deleting old backups"
find $_backupPath/$_site* -mtime +8 -exec rm {} ;
echo "Backing up $_tarFile"
tar -zcf $_tarFile $_homePath/$_site
echo ""
echo "Backing up $_sqlFile"
mysqldump -c -h $_sqlHost --user=$_sqlUser --password=$_sqlPass $_sqlDb > $_sqlFile
echo ""
echo "Listing Backup Directory..."
ls -alht $_backupPath


Related posts

2 Thoughts to “Backing up sites on Dreamhost”

  1. One approach to multi-folder & multi-database backup:

    Also, look into ADisk for FTP/SCP/RSYNC transfer off of Dreamhost servers

  2. Another nice function to add in the log: summarizing the sizes of the backup directories.

Leave a Reply