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.
To download and install AutoMySQLBackup on your account, follow these steps:
tar xvzf automysqlbackup-v3.0_rc6.tar.gz
To install AutoMySQLBackup, type the following command:
At the Select the global configuration directory prompt, type the path where the configuration files will be stored.
At the Select directory for the executable prompt, type the path where the program file will be stored.
If you are installing AutoMySQLBackup on a shared hosting account, you may receive the following message:
exists already ... searching for config files: Found config file /home/username/*.conf. head: cannot open `/home/username/*.conf' for reading: No such file or directory No version information on first line of config file. Assuming the version is <3. Convert? [Y/n]
If you receive this message, type n and then press Enter to complete the installation.
After you download and install AutoMySQLBackup, you can configure the settings for your own environment. To do this, follow these steps:
CONFIG_mysql_dump_username='username' CONFIG_mysql_dump_password='password' CONFIG_backup_dir='/home/username/mysqlbackups'
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:
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:
CONFIG_rotation_daily=6 CONFIG_rotation_weekly=35 CONFIG_rotation_monthly=150
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_mailcontent='files' CONFIG_mail_use_uuencoded_attachments='yes' CONFIG_mail_address='[email protected]'
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:
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:
For more information about how to use cPanel to create a cron job, please see this article.