Created
August 29, 2012 05:23
-
-
Save initcron/3507089 to your computer and use it in GitHub Desktop.
/root/xtra_mysqlbackup.sh
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 | |
BACKUP_DIR=/backups | |
PASS="randompasswordhere" | |
MYSQL_CONFIG=/etc/mysql/my.cnf | |
echo "Creating Backup..." | |
innobackupex --defaults-file=$MYSQL_CONFIG --password=$PASS $BACKUP_DIR/ | |
echo "DONE Creating Backup!" | |
NEWPATH=`ls -tr /$BACKUP_DIR/ | tail -n 1` | |
echo "Preparing Backup..." | |
innobackupex --defaults-file=$MYSQL_CONFIG --password=$PASS --apply-log /$BACKUP_DIR/$NEWPATH | |
echo "Done Preparing Backup!" | |
echo "Cleaning up backups older than 7 days..." | |
cd $BACKUP_DIR && find /$BACKUP_DIR/ -type d -mtime +7 -exec rm -rf '{}' \; | |
echo "ALL DONE!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment