Skip to content

Use AutoMySQLBackup for daily backups

AutoMySQLBackup is an easy-to-use script that creates daily, weekly, and monthly backups of your MySQL databases.

Install AutoMySQLBackup

Install AutoMySQLBackup by running the following command as root:

Terminal window
sudo apt-get install automysqlbackup

Once installed, the script will automatically run once a day to create a backup of each MySQL database on your server.

Configuration file

To change the directory where backups are stored or to exclude certain databases from backups, edit the following file.

/etc/default/automysqlbackup

Configuration options are described in the automysqlbackup man page.

Run backups manually

After installing AutoMySQLBackup or making configuration changes, you may want to run the automysqlbackup command manually to ensure backups are working as intended.

Terminal window
sudo automysqlbackup

Location of backups

By default, backups are stored in the following directory.

/var/lib/automysqlbackup/

Within the above directory will be three directories, one for each backup frequency:

  • daily/
  • weekly/
  • monthly/

Within each of the backup frequency directories will be a separate directory for each database which contains compressed backups with the date of each backup in the filename.

To see all backups, list the contents of /var/lib/automysqlbackup/ recursively.

Terminal window
ls -R /var/lib/automysqlbackup/

The output of the above command will look similar to the following:

/var/lib/automysqlbackup/:
daily monthly weekly
/var/lib/automysqlbackup/daily:
exampledb information_schema performance_schema test wordpress
/var/lib/automysqlbackup/daily/exampledb:
exampledb_2014-08-03_06h48m.Sunday.sql.gz
...