Created
April 14, 2014 03:02
-
-
Save jmaddington/10612871 to your computer and use it in GitHub Desktop.
MySQL Dumps
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
#Change lines 6 & 10 to where you want to store your backups | |
echo 'show databases;'|/usr/bin/mysql --skip-column-names|while read -r db | |
do | |
fn=`date +%Y%m%d%H%S` | |
nice /usr/bin/mysqldump $db| bzip2 -9 > /root/backups/mysql/hourly/$fn.$db.sql.bz2 | |
done | |
#Change +3 to however many days you want to keep backups | |
find /root/backups/mysql/hourly/ -ctime +3 -exec rm "{}" \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment