Backup MySQL Database to Dropbox

admin

Administrator
Staff member
In the past I have received a lot of help from the SO community, so once I figured this out, I thought here's my opportunity to give back a little. Hopefully it helps someone.

The issue I was faced with was having my core site built on WordPress, with another database for an e-commerce section of the site, I wanted to backup the entire site (all files, both databases, etc.) to Dropbox on a daily basis.

After a lengthy search, I couldn't find anything that did exactly what I was looking for.

<strong>Disclaimer: You don't need to be running WordPress or an e-commerce site for this to work. It will work on any MySQL database(s) and requires PHP.</strong>

I came across the <a href="http://wordpress.org/plugins/wordpress-backup-to-dropbox/">WordPress Backup to Dropbox plugin</a>, which got me about 90% there. The plugin allowed me to back up all the files on the site plus it does a WordPress database backup at a frequency you schedule.

The problem is that the plugin <em>only</em> does a backup of the WordPress database, but not my e-commerce database.

I also found a <a href="http://ericsilva.org/2012/07/05/backup-mysql-database-to-dropbox/">MySQL backup to Dropbox</a> tutorial (credit where it's due), which some of the code below is based on. It is a great tutorial, but I wanted it to backup and delete the backup at different times - the tutorial backed up and deleted all at the same time.