AutoMySQLBackup is a free and open source tool that can be used to create backups of your MySQL databases at varying intervals, such as daily, weekly, and monthly. It uses mysqldump to create backups of one or more MySQL databases from one of more MySQL servers. It provides lots of features such as email notification, incremental database backups, backup compression and encryption, and much more.
In this tutorial, we will explain how to install and use AutoMySQLBackup on Ubuntu 16.04 server.
- A Vultr Ubuntu 16.04 server instance.
- A working MySQL Server.
- A sudo user.
Step 1: Install AutoMySQLBackup
Before installing AutoMySQLBackup, make sure your system is up-to-date.
You can do this by running the following command:
sudo apt-get update -y sudo apt-get upgrade -y sudo shutdown -r now
Next, install AutoMySQLBackup from the Ubuntu repository with the following command:
sudo apt-get install automysqlbackup
Once the installation is complete, you can proceed to configure AutoMySQLBackup.
Step 2: Configure AutoMySQLBackup
In order to configure AutoMySQLBackup, you will need to edit its configuration file located in
sudo nano /etc/automysqlbackup/automysqlbackup.conf
Change the file as per your requirements:
CONFIG_mysql_dump_username='root' CONFIG_mysql_dump_password='password' CONFIG_mysql_dump_host='localhost' CONFIG_backup_dir='/var/backup/db' CONFIG_do_monthly="01" CONFIG_do_weekly="5" CONFIG_rotation_daily=6 CONFIG_rotation_weekly=35 CONFIG_rotation_monthly=150 CONFIG_mysql_dump_port=3306 CONFIG_mysql_dump_compression='gzip'
Save and close the file when you are finished.
All the above settings are optional. So it is a good idea to check the configuration file for more information about the settings of AutoMySQLBackup.
Next, create a directory for storing MySQL backup.
sudo mkdir /var/backup
Finally, run the following command to create a backup of your MySQL databases:
You don’t want to run automysqlbackup manually all the time. You can create a daily cron job for it as below:
sudo ln -s /usr/local/bin/automysqlbackup /etc/cron.daily/
This concludes our tutorial. Thank you for reading.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article