Automatic MySQL Backups

This feature goes perfectly with my previous article on Google Drive Syncing. If you pair it with these automatic backups you can have your mysql backups automatically sync to your google drive account. I recommend checking that article out first then returning here and completing this guide as well.


Ubuntu has a package in it’s repos called “automysqlbackup” that is dirt simple to get running out of the box.

Now here is where you can customize it. The configuration file has a setting that tells it where to create the backup files.

Look for the line that reads

Change it to where you want the backups stored. If you followed my previous Google Drive guide that would be something similar to this

If you are using Google Drive to back these up you will have one more step. This is due to the fact that the backup files are created as root and grive will run into permission issues trying to sync.

To fix this we will be modifying the grive bash script to change the permissions on the folder (and it’s contents) and then execute grive.

Modify it to look similar to this

Save the file and you are done.

You can kick it off manually or wait for the cron to execute on it’s own.

*HINT* re-read the google drive article to make sure you haven’t missed anything. specifically make sure to execute the cron from sudo crontab -e so the chmod and chown lines will not fail.

Posted in Server Admin Tagged with: , , , , , ,
2 comments on “Automatic MySQL Backups
  1. Daniel says:

    Thank you for the nice tutorial. However, I encountered error when chmod and chown since the files generated by automysqlbackup has root owner and 000 permissions. The files are not syncing to google drive

    Any help on fix this error?

Leave a Reply

Your email address will not be published. Required fields are marked *