Holland is an open source backup framework written in Python. It can be used to back up several different database types using a number of methods based on the plugins you choose to install. In this tutorial we will cover how to on install and configure Holland to backup a MariaDB or MySQL databases using the common mysqldump method on CentOS 7 / RHEL 7.
0./ Create a backup user:
– We are going to create a backup user in the MariaDB Master where Holland backup will use it:
[root@sqlmaster ~]# mysql -u root -p MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'your_user_backup_name_here'@'%' IDENTIFIED BY 'your_user_backup_password_here' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit
1./ Install Holland and Dependencies:
– Before proceeding the installation the holland backup and Dependencies you have to install the EPEL Repository:
[root@sqlslave ~]# sudo yum install epel-release [root@sqlslave ~]# sudo yum install holland holland-common holland-mysqldump
2./ Configure a Backup task with Holland
– The default holland backup jobs location is /etc/holland/backupsets/ where you can create new backup jobs. Let’s create a new backup job file:
[root@sqlslave ~]# cat << END > /etc/holland/backupsets/default.conf ## ## Default Backup-Set ## ## Backs up all MySQL databases in a one-file-per-database fashion using ## lightweight in-line compression and engine auto-detection. This backup-set ## is designed to provide reliable backups "out of the box", however it is ## generally advisable to create additional custom backup-sets to suit ## one's specific needs. [holland:backup] plugin = mysqldump backups-to-keep = 1 auto-purge-failures = yes purge-policy = after-backup estimated-size-factor = 1.0 # This section defines the configuration options specific to the backup # plugin. In other words, the name of this section should match the name # of the plugin defined above. [mysqldump] file-per-database = yes #lock-method = auto-detect #databases = "*" #exclude-databases = "foo", "bar" #tables = "*" #exclude-tables = "foo.bar" #stop-slave = no #bin-log-position = no # The following section is for compression. The default, unless the # mysqldump provider has been modified, is to use inline fast gzip # compression (which is identical to the commented section below). [compression] method = gzip options = "--rsyncable" [mysql:client] defaults-extra-file = /root/.my.cnf END
3./ Creation .my.cnf file
– In the default.conf file created we have set defaults-extra-file to /root/.my.cnf, for that reason we have to create /root/.my.cnf file and put the database credentials into it.
[root@sqlslave ~]# cat << END > /root/.my.cnf [client] user = your_user_backup_name_here password = your_user_backup_password_here host = your_master_server_ip_here END
4./ Schedule a Backup Job using Cron
– We can use cron to schedule Holland backup job. In this example, we will configure a typical daily backup by editing root’s crontab that will be run everyday at 18:01.
[root@sqlslave ~]# sudo crontab -e -u root 01 18 * * * holland -q bk
– By default the backup location is under the directory /var/spool/holland/ you can modify it by editing the default configuration file /etc/holland/holland.conf and change the backup_directory setting.
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.