Skip to content

Backing up MySQL databases using AutoMySQLBackup

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.

Downloading and installing AutoMySQLBackup

Section titled “Downloading and installing AutoMySQLBackup”
  1. Go to SourceForge and download the .tar.gz file.

  2. Upload the .tar.gz file to your hosting account using FTP, SFTP, or cPanel File Manager.

  3. Log in to your account using SSH.

  4. Navigate to the directory where you uploaded the file.

  5. Extract the files:

    tar xvzf automysqlbackup-v3.0_rc6.tar.gz

    Note: The filename may differ slightly depending on the version.

  6. Install AutoMySQLBackup:

    ./install.sh
  7. Specify the configuration directory path and the executable directory path when prompted.

  1. Log in using SSH.

  2. Open myserver.conf in your preferred text editor (located in the configuration directory).

  3. 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.

  4. To back up specific databases, uncomment and update:

    CONFIG_db_names=()

    By default, all databases are backed up.

  5. Configure rotation settings:

    CONFIG_rotation_daily=6
    CONFIG_rotation_weekly=35
    CONFIG_rotation_monthly=150
  6. 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.

  7. Save and exit the file.

  • 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.