Skip to content

Instantly share code, notes, and snippets.

@tanji
Created December 9, 2014 14:11
Show Gist options
  • Save tanji/53007cbf9c35c9b3ecc9 to your computer and use it in GitHub Desktop.
Save tanji/53007cbf9c35c9b3ecc9 to your computer and use it in GitHub Desktop.
Simple innobackupex wrapper
#!/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