12-15-2020, 09:31 AM
Auto MySQL Backup is a command line utility that is distributed under the GNU license. This utility allows you to automate the backup process for the MySQL database, and it also allows you to perform incremental backups.
Installation
If your Linux distribution is Debian, then AutoMySQLBackup is available in the repository, and you can install it simply by running the following command:
sudo apt-get install automysqlbackup
If your Linux distribution is RPM-based, the setup process will be a little bit more involved.
1. Download the latest version of AutoMySQLBackup:
wget https://github.com/sixhop/AutoMySQLBacku...master.zip
2. Create a directory and unzip the downloaded archive
mkdir /opt/automysqlbackup mv AutoMySQLBackup-master.zip cd /opt/automysqlbackup tar -zxvf AutoMySQLBackup-master.zip
3. Then install AutoMySQLBackup.
./install.sh
AutoMySQLBackup Settings
To configure AutoMySQLBackup, you must edit the file automysqlbackup.conf:
sudo nano /etc/automysqlbackup/automysqlbackup.conf
AutoMySQLBackup contains many settings, and you can find the full list in the official documentation.
Please note the following:
1. Path to the configuration file
CONFIG_configfile="/etc/automysqlbackup/automysqlbackup.conf"
2. The path to the backup storage directory
CONFIG_backup_dir='/var/backup/db'
3. Information for connecting to MySQL
CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password='my_password'
CONFIG_mysql_dump_host='localhost'
4. List of databases that you need or do not need to back up
CONFIG_db_names=('my_db')
CONFIG_db_exclude=('information_schema')
5. Email notification address
CONFIG_mail_address='mail@google.com'
6. Options for scheduling
CONFIG_rotation_daily=6
CONFIG_rotation_weekly=35
CONFIG_rotation_monthly=150
7. Run bash script after backup
POSTBACKUP="/etc/mysql-backup-post"
If you plan to store backups for a limited number of days, then you can delete backups by configuring the POSTBACKUP script as follows:
#!/bin/bash
# Delete backups that are older than 30 days
find /var/backup/db -mtime +30 -delete
By default, AutoMySQLBackup will compress the files using ‘gzip’. You can change this by editing the CONFIG_mysql_dump_compression parameter. If you want to add encryption, then use the CONFIG_encrypt and CONFIG_encrypt_password parameters.
Running
To run AutoMySqlBackup execute the following command:
automysqlbackup /etc/automysqlbackup/automysqlbackup.conf
Installation
If your Linux distribution is Debian, then AutoMySQLBackup is available in the repository, and you can install it simply by running the following command:
sudo apt-get install automysqlbackup
If your Linux distribution is RPM-based, the setup process will be a little bit more involved.
1. Download the latest version of AutoMySQLBackup:
wget https://github.com/sixhop/AutoMySQLBacku...master.zip
2. Create a directory and unzip the downloaded archive
mkdir /opt/automysqlbackup mv AutoMySQLBackup-master.zip cd /opt/automysqlbackup tar -zxvf AutoMySQLBackup-master.zip
3. Then install AutoMySQLBackup.
./install.sh
AutoMySQLBackup Settings
To configure AutoMySQLBackup, you must edit the file automysqlbackup.conf:
sudo nano /etc/automysqlbackup/automysqlbackup.conf
AutoMySQLBackup contains many settings, and you can find the full list in the official documentation.
Please note the following:
1. Path to the configuration file
CONFIG_configfile="/etc/automysqlbackup/automysqlbackup.conf"
2. The path to the backup storage directory
CONFIG_backup_dir='/var/backup/db'
3. Information for connecting to MySQL
CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password='my_password'
CONFIG_mysql_dump_host='localhost'
4. List of databases that you need or do not need to back up
CONFIG_db_names=('my_db')
CONFIG_db_exclude=('information_schema')
5. Email notification address
CONFIG_mail_address='mail@google.com'
6. Options for scheduling
CONFIG_rotation_daily=6
CONFIG_rotation_weekly=35
CONFIG_rotation_monthly=150
7. Run bash script after backup
POSTBACKUP="/etc/mysql-backup-post"
If you plan to store backups for a limited number of days, then you can delete backups by configuring the POSTBACKUP script as follows:
#!/bin/bash
# Delete backups that are older than 30 days
find /var/backup/db -mtime +30 -delete
By default, AutoMySQLBackup will compress the files using ‘gzip’. You can change this by editing the CONFIG_mysql_dump_compression parameter. If you want to add encryption, then use the CONFIG_encrypt and CONFIG_encrypt_password parameters.
Running
To run AutoMySqlBackup execute the following command:
automysqlbackup /etc/automysqlbackup/automysqlbackup.conf