Backing up MySQL databases using AutoMySQLBackup
This article explains how to use the AutoMySQLBackup tool to back up MySQL databases. AutoMySQLBackup allows flexible backup intervals—daily, weekly, or monthly—and can rotate backups to save storage. You can also send backups to an external email address for off-site redundancy.
| Note Server Rewind on managed VPS accounts does not include database backups, so you should set up your own backups. AutoMySQLBackup does not work on Shared, Reseller, or CloudLinux Dedicated servers. Hosting.com servers support many applications, but we cannot provide troubleshooting for application-specific issues. |
Downloading and installing AutoMySQLBackup
-
Go to SourceForge and download the
.tar.gzfile. -
Upload the
.tar.gzfile to your hosting account using FTP, SFTP, or cPanel File Manager. -
Log in to your account using SSH.
-
Navigate to the directory where you uploaded the file.
-
Extract the files:
tar xvzf automysqlbackup-v3.0_rc6.tar.gzNote: The filename may differ slightly depending on the version.
-
Install AutoMySQLBackup:
./install.sh -
Specify the configuration directory path and the executable directory path when prompted.
Configuring AutoMySQLBackup
-
Log in using SSH.
-
Open
myserver.confin your preferred text editor (located in the configuration directory). -
Configure basic settings by uncommenting and updating these lines:
CONFIG_mysql_dump_username='username' CONFIG_mysql_dump_password='password' CONFIG_backup_dir='/home/username/mysqlbackups'Note: Use your MySQL credentials, not SSH credentials. Ensure the backup directory exists.
-
To back up specific databases, uncomment and update:
CONFIG_db_names=()By default, all databases are backed up.
-
Configure rotation settings:
CONFIG_rotation_daily=6 CONFIG_rotation_weekly=35 CONFIG_rotation_monthly=150 -
To send backups via email, uncomment and modify:
CONFIG_mailcontent='files' CONFIG_mail_use_uuencoded_attachments='yes' CONFIG_mail_address='user@example.com'Important: Store backups off-server periodically for added security.
-
Save and exit the file.
Running a backup
-
To run a manual backup:
automysqlbackup "path/myserver.conf" -
To automate backups, create a cron job with the command:
/home/username/path/automysqlbackup "path/myserver.conf"
For guidance on creating cron jobs in cPanel, please see this article.