How to install and configure schedule AutoMySQLBackup

How to install and configure AutoMySQLBackup

In this blog article, we will show you how to install AutoMySQLBackup on a Linux or Unix based operating system. AutoMySQLBackup is a very useful utility for creating daily, weekly or monthly backups of one or more MySQL databases. It dumps the databases and compresses them into archives and send email notification.

AutoMySQLBackup Features

  • Email notification of backups on failure
  • Backup Compression and Encryption
  • Configurable backup rotation daily,weekly, monthly
  • Incremental database backups

As usual, log in to your server as user root

[root@local ~]#ssh root@serverip

AutoMySQLBackup  for Debian based systems execute

If you are running Debian based distro AutoMySQLBackup is available in the repositories and you can easily install it by executing the following

[root@sudoadmin ~]#apt-get update && apt-get upgrade
[root@sudoadmin ~]#apt-get install automysqlbackup

AutoMySQLBackup for RPM based systems execute

If you have an RPM based distro you will have to download AutoMySQLBackup’s installation scripts, run and configure them on your server. In this tutorial, we will install Automysqlbackup on a CentOS.

1. Download AutoMySQLBackup

Download the latest version of AutoMySQLBackup to your server

[root@sudoadmin ~]#wget http://www.sudoadmin.com/DownLoads/automysqlbackup/automysqlbackup-v3.0_rc6.tar.gz

2. Extract AutoMySQLBackup

Create a directory for Automysqlbackup’s scripts and unpack the downloaded tar archive in that directory

[root@sudoadmin ~]#mkdir /opt/automysqlbackup
[root@sudoadmin ~]#mv automysqlbackup-v3.0_rc6.tar.gz
[root@sudoadmin ~]#cd /opt/automysqlbackup
[root@sudoadmin ~]#tar -zxvf automysqlbackup-v3.0_rc6.tar.gz

3. Install AutoMySQLBackup

Once the archive is unpacked run the Automysqlbackup installation script

[root@sudoadmin ~]#cd /opt/automysqlbackup
[root@sudoadmin ~]#./install.sh

### Checking archive files for existence, readability and integrity.

automysqlbackup ... exists and is readable ... md5sum okay :)
automysqlbackup.conf ... exists and is readable ... md5sum okay :)
README ... exists and is readable ... md5sum okay :)
LICENSE ... exists and is readable ... md5sum okay :)

Select the global configuration directory [/etc/automysqlbackup]:
Select directory for the executable [/usr/local/bin]:
### Creating global configuration directory /etc/automysqlbackup:

success

4. Configuration AutoMySQLBackup

You can use the default paths for the global configuration directory and the directory for the executable. You just have to press Enter when the paths are required.

Next, we have to configure AutoMySQLBackup. Open its configuration file located in the directory we set when we ran the installation script.

[root@sudoadmin ~]#vi /etc/automysqlbackup/automysqlbackup.conf

And uncomment and set the following configuration directives

CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password='password'
CONFIG_mysql_dump_host='localhost'
CONFIG_mysql_dump_host_friendly='sudoadmin'
CONFIG_backup_dir='/backup/'
CONFIG_db_names=( 'databasename1' 'databasename2')
CONFIG_db_exclude=( 'information_schema' )
CONFIG_do_monthly="01"
CONFIG_do_weekly="5"
CONFIG_rotation_daily=30
CONFIG_mysql_dump_single_transaction='yes'
CONFIG_mysql_dump_dbstatus='yes'
CONFIG_mysql_dump_create_database='no'
CONFIG_mysql_dump_use_separate_dirs='yes'
CONFIG_mysql_dump_compression='gzip'
CONFIG_mailcontent='log'
CONFIG_mail_maxattsize=4000
CONFIG_mail_splitandtar='yes'
CONFIG_mail_address='sysadmin@exapmle.com'

Once you are done with editing, save the configuration file. All settings are optional and there is the description for all of them, so it is best to check the configuration file for more information about the settings of AutoMySQLBackup.

Create a directory for the MySQL backups. This is the directory we set as ‘/backup’ in the configuration file.

[root@sudoadmin ~]#mkdir /backup

5. Execute AutoMySQLBackup

If you want to create a backup of your MySQL databases, run AutoMySQLBackup by executing the following

/usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf

6. Schedule AutoMySQLBackup

You can also create a crontab entry to run AutoMySQLBackup at a specific time.
eg. backup is scheduled at 1 AM.

[root@sudoadmin]#crontab -e

0 1 * * * /usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf

That’s all. You can check the /etc/automysqlbackup/README file for more information on how to use AutoMySQLBackup.

Leave a Reply

avatar
  Subscribe  
Notify of