Created
December 9, 2014 14:11
-
-
Save tanji/53007cbf9c35c9b3ecc9 to your computer and use it in GitHub Desktop.
Simple innobackupex wrapper
This file contains 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 | |
TODAY=$(date +%Y%m%d) | |
DOW=$(date +%w) | |
# check if sshfs is mounted. if not, do it | |
mount -f /mnt/backup | |
if [ $? -eq 0 ] | |
then | |
mount /mnt/backup | |
fi | |
mysql --password=foo! -e "set global wsrep_desync=ON" | |
# if day of week = Sunday then do full backup | |
if [ $DOW -eq 0 ] | |
then | |
innobackupex /mnt/backup/$TODAY --password=foo! --compress --history=dbcluster1 --compress-threads=4 --no-timestamp &> /mnt/backup/backup.$TODAY.log | |
else | |
# do incremental backup | |
innobackupex /mnt/backup/$TODAY --password=foo! --compress --incremental --incremental-history-name=dbcluster1 --compress-threads=4 --no-timestamp &> /mnt/backup/backup.$TODAY.log | |
fi | |
# Re-enable node sync after backup and monyog notification. | |
mysql -pttService! -e "set global wsrep_desync=OFF" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment