Auto backup solution for your MySQL databases

I use MySQL as my database server, and thankfully, it’s been reliable and easy to use.  A qualm I have, however, is that it doesn’t include a daily backup feature, unlike Microsoft SQL Server.

The good thing is that the open source community has seen this problem and created a solution for it: AutoMySQLBackup.  (You can download it from here.)

According to the website on SourceForge.net:

A script to take daily, weekly and monthly backups of your MySQL databases using mysqldump. Features – Backup mutiple databases – Single backup file or to a seperate file for each DB – Compress backup files – Backup remote servers – E-mail logs – More..

Here are the quick-and-dirty set up steps (courtesy of debianhelp.co.uk):

1.  Download automysqlbackup.sh and place it into your /etc/cron.daily directory like so: cp /path-to-automysqlbackup/automysqlbackup.sh /etc/cron.daily/.

2.  Edit (at least) the following lines via vim automysqlbackup.sh:
USERNAME=dbuser
PASSWORD=password
DBNAMES=”DB1 DB2 DB3″

3.  Make the file executable by typing: chmod u+rwx automysqlbackup.sh.

4.  Create the following directory by typing: mkdir ./backups.

5.  That’s it!  You can either run the script via the command line: ./automysqlbackup.sh, or let it run its course since we’ve now put it in /etc/cron.daily; make sure the cron service is running, though.  ;0)

Peace. \m/

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.