In this post, I will explain to you how we can set our MySQL database to auto backup. MySQL also provides a command-line utility to backup your database using mysqldump, for exporting databases as raw SQL. You need to run mysqldump every time whenever you want to take backup but you can automate this process using AutoMySQLBackup which takes backup of your database daily, weekly, and monthly.

Please follow the below steps to install AutoMySQLBackup in your server.

Step 1. Open the terminal and login to your server.

Step 2. You can install AutoMySQLBackupfrom Ubuntu repositories, run below command as root.

sudo apt-get install automysqlbackup

Once you run command and AutoMySQLBackup is installed you can find AutoMySQLBackup folder inside /var/lib/.

Step 3. Now we can check if AutoMySQLBackup is configured properly or not. To run AutoMySQLBackup to take backup manually rather than waiting for it to be run the first time.

sudo automysqlbackup

After running above command as root you will get list all of the files under /var/lib/automysqlbackup/.

Or you can run the below command to get list of folder in automysqlbackup directory.

ls -R /var/lib/automysqlbackup/

If your AutoMySQLBackup is configured properly you will get backup of your all database in .sql.gz files.

You can also change the configuration of your AutoMySQL backup by editing your automysqlbackup file.

/etc/default/automysqlbackup

Hope this post helps you to set up your MySQL auto backup.