How to back up MySQL databases using AutoMySQLBackup

This article describes how to use the AutoMySQLBackup tool to back up MySQL databases.

AutoMySQLBackup is a flexible script that enables you to create backups at varying intervals, such as daily, weekly, and monthly. By rotating your backups, you can preserve storage space on your account. You can even send backup files to external e-mail accounts for off-site backup redundancy.

  • Server Rewind on managed VPS accounts does not include database backups and restores, so you should follow the procedures below to set up your own database backups on a managed VPS. AutoMySQLBackup does not work on Shared and Reseller servers, or on Dedicated servers running CloudLinux.
  • Although A2 Hosting servers are compatible with a wide variety of software applications, we cannot provide troubleshooting assistance for application-specific issues. The procedures below are for demonstration purposes only.

Downloading and installing AutoMySQLBackup

To download and install AutoMySQLBackup on your account, follow these steps:

  1. Use your web browser to go to, and then click Download. Save the .tar.gz file on your computer.
  2. Upload the .tar.gz file to your A2 Hosting account. To do this, you can use FTP, SFTP, or the cPanel File Manager (if your account includes cPanel access).
  3. Log in to your account using SSH.
  4. At the command prompt, change to the directory where you uploaded the .tar.gz file in step 2.
  5. To extract the application files from the .tar.gz file, type the following command:
    tar xvzf automysqlbackup-v3.0_rc6.tar.gz
    The exact filename may differ slightly, depending on the version you downloaded.
  6. To install AutoMySQLBackup, type the following command:

  7. At the Select the global configuration directory prompt, type the path where the configuration files will be stored.
  8. At the Select directory for the executable prompt, type the path where the program file will be stored.


Configuring AutoMySQLBackup

After you download and install AutoMySQLBackup, you can configure the settings for your own environment. To do this, follow these steps:

  1. Log in to your account using SSH.
  2. Use a text editor to edit the myserver.conf file. The myserver.conf file is located in the configuration directory that you specified in the previous procedure.
  3. To configure basic backup settings, remove the pound sign (#) from the start of the following lines in the myserver.conf file, and then change the values to match your own installation:
    Make sure you use a MySQL username and password, and not the username and password you use to log in to SSH. Addtionally, make sure that the path you specify for the backup directory exists. AutoMySQLBackup does not automatically create the directory.
  4. To specify specific databases to back up, remove the pound sign (#) from the start of the following line, and change the value to the databases you want to back up:

    By default, AutoMySQLBackup backs up all MySQL databases. You only need to change this setting if you want to back up specific databases.
  5. To specify rotation settings for the different backup intervals, remove the pound sign (#) from the start of the following lines, and then change the values to the rotation settings that you want:

  6. To send backup files to an e-mail account, remove the pound sign (#) from the start of the following lines, and then modify them as shown. Replace [email protected] with the e-mail address where you want to send the backup files:

    CONFIG_mail_address='[email protected]'
    A2 Hosting strongly recommends that you periodically store database backup files at a location separate from the web server. The e-mail feature in AutoMySQLBackup is one way to easily accomplish this.
  7. Save the changes to the myserver.conf file and exit the text editor.

Running a backup

After you configure AutoMySQLBackup for your environment, you can run backups. To run a backup manually using AutoMySQLBackup, type the following command. Replace path with the path to the myserver.conf file:

automysqlbackup "path/myserver.conf"

However, you will most likely want to automate the process and create backups automatically. To do this, you can set up a cron job that runs the following command. Replace the username and path values as required by your own configuration:

/home/username/path/automysqlbackup "path/myserver.conf"

For more information about how to use cPanel to create a cron job, please see this article.

Get MySQL Hosting

Article Details

  • Level: Intermediate

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.