Backup MySQL Databases Automatically on a Linux Server

Dumping a MySQL database to a file is not a difficult task, but it is nice to be able to automate the process and have several versions archived. There is a project called “AutoMySQLBackup” available at:

First you should download the script to your Linux host using wget:

host#> wget

Rename the file:

host#> mv to

Make the file executable:

host#> chmod 755

Next you should move the file to a place convenient for you. I personally have a folder called “/etc/cron.other” for such scripts.

host#> mv /etc/cron.other/

You'll now want to edit the script for your personal preference.

host#> vi /etc/cron.other/

You will need edit a couple of items.


The advantage of using the root MySQL password, and selecting “all” for the databases, is that dyou don't have to create a new script everytime you add a database to system.

Now we need to add the script to the crontab to run everyday.

host#> crontab -e

Add a line such as:

0 1 * * * /etc/cron.other/

When done type:


…to save and exit the crontab editing.

This will cause the script to be run nightly at 1am. When the script is finished it will send an email to the address provided above in the MAILADDR variable.

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.