How To Set Up Automatic Backups of your Godaddy Website and Databases

I had a client that recently wanted to start backing up all of the data from his websites to an external hard drive. I was like, “Ok, that’s easy. GoDaddy creates daily backups of your files that you can zip up from your account and download.” Wrong.

Godaddy does create daily backs, which you can zip up and download, but not if your trying anything over 10 MB or so. Also, it DOES NOT create backups of your databases. But that’s ok, cron jobs to the rescue.

To create the necessary backups I needed to do the following:

1) Write a script that would generate backups of all the databases and store them in a private zone
2) Write a script that would create a zip file of the entire site
3) Add both of these as cron jobs

1) backupmydatabases


// Just create a sql dump of the database.
// Do this for each database that you need to backup

2) backupmyfiles


// Remove the previous backup file.
rm -f ~/private/access/fullsite_backup.tar.gz

// Create a tarball file of everything in your pocket of the server
// Dont include the actual tarball!!
tar --exclude=~/private/access/fullsite_backup.tar.gz -czf ~/private/access/fullsite_backup.tar.gz ~/*

3) Godaddy Crons

Now you just go to your Godaddy account and setup 2 cron jobs to run each of those scripts. Make sure you run the database backup script first and allow enough time for it to finish before you start the file backup script!

All you have to do now to get a backup of your entire webserver is just download the fullsite_backup.tar.gz file.