Created
February 6, 2020 10:07
-
-
Save mshafiee/200d9a7cb6d185fbec914613dbb05a4d to your computer and use it in GitHub Desktop.
Backup Percona MySQL Galera Cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[client] | |
user=backup | |
password=ffgf43rger43gtregrt43hr23 | |
[mysqld] | |
socket=/var/run/mysqld/mysqld.sock | |
datadir=/var/lib/mysql | |
innodb_log_group_home_dir=/var/lib/mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mysql-full-backup.sh | |
mysql --defaults-extra-file=/etc/backup-my.cnf -e 'set GLOBAL wsrep_desync=ON;' | |
# Change directories to the backup location. | |
mkdir -p "/mnt/SSD/backup/$(date +%d-%m-%Y)" && cd "/mnt/SSD/backup/$(date +%d-%m-%Y)" | |
# Execute the compressed and encrypted full backup. | |
#innobackupex --defaults-file=/etc/backup-my.cnf \ | |
# --no-lock \ | |
# --no-timestamp \ | |
# --use-memory=1G \ | |
# --stream=xbstream \ | |
# --parallel=4 \ | |
# --history=$(date +%d-%m-%Y) ./ > \ | |
# mysqlbackup$(date +%d-%m-%Y).qp.xbc.xbs 2> \ | |
# backup-progress.log && find /backups/* -type d -atime +10 -exec rm -rf {} \; & | |
#backup-progress.log && s3cmd --limit-rate=7000k put mysqlbackup$(date +%d-%m-%Y).qp.xbc.xbs s3://snapp-backups/mysqlbackup$(date +%d-%m-%Y).qp.xbc.xbs && find /backups/* -mtime +7 -exec rm -rf {} \; & | |
innobackupex --defaults-file=/etc/backup-my.cnf \ | |
--no-lock \ | |
--no-timestamp \ | |
--use-memory=1G \ | |
--parallel=4 \ | |
--galera-info \ | |
. \ | |
> ../backup-progress.log 2>&1 && innobackupex --apply-log . > ../backup-progress.log 2>&1 && find /mnt/SSD/backup/ -maxdepth 1 -type d -mtime +4 -exec rm -rf {} \; && mysql --defaults-extra-file=/etc/backup-my.cnf -e 'set GLOBAL wsrep_desync=OFF;' & | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
02 1 * * * /root/backup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment