====== Percona ======
Percona is a tool that aids us in creating database backups. There is a playbook in the database-setup project that can install it on a target server and there is work ongoing to automate the backups.
Percona is useful for very large databases as it is much quicker than using standard mysqldump files to backup databases. One thing to make note of though is that you will need enough space on the disk to hold a complete backup or mirror of the mysql data directory.
The backup step looks like this, here we specify the mysql data directory, a target directory and exclude the varbind table.
xtrabackup --backup --datadir={{mysql_data_dir}} --target-dir={{source_backup_dir}} --tables-exclude=\"snmp_manager.varbind\" --user='{{global_db_username}}' --password='{{global_db_password}}';
This step can take a while depending on the size of the database. Once the backup is complete it must be prepared. Mysql will not work with this backup until this step is performed. This is the command.
xtrabackup --prepare --user='{{global_db_username}}' --password='{{global_db_password}}' --target-dir={{source_backup_dir}};
Now that we have the backup complete we will sync it to the target server using rsync. Make sure you change the files in the backup directory to be owned by scotty user.
Here we are transferring the backup directory to the mysql data directory on the target server. This can take upwards of 2 hours to complete for ExteNet data. The -P option will show an output with the estimated time remaining for each file. For this command to work you will need to change ownership of /var/lib/mysql to scotty.
rsync -e "ssh -o StrictHostKeyChecking=no" -arvpP scotty@{{target_server}}:/{{source_backup_dir}}/ /var/lib/mysql/
Once this is complete we can change the ownership back to mysql user and start the service.