Created
February 24, 2011 00:56
-
-
Save bleepbloop/841538 to your computer and use it in GitHub Desktop.
main decision tree of SQL cron
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
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
if [ $1 ] | |
then | |
for (( i=$(expr $RETENTION - 1); i>0; i-- )) | |
do | |
if [ -f $BAK_PATH/$HOST.sql.$i ] | |
then | |
mv $BAK_PATH/$HOST.sql.$i $BAK_PATH/$HOST.sql.$(expr $i + 1) | |
fi | |
done | |
mv $BAK_PATH/$HOST.sql $BAK_PATH/$HOST.sql.1 | |
ssh $1 "mysqldump -u$SQL_USERNAME -p$SQL_PASSWORD --all-databases" > $BAK_PATH/$HOST.sql | |
else | |
for (( i=$(expr $RETENTION - 1); i>0; i-- )) | |
do | |
if [ -f $BAK_PATH/`hostname`.sql.$i ] | |
then | |
mv $BAK_PATH/`hostname`.sql.$i $BAK_PATH/`hostname`.sql.$(expr $i + 1) 2>&1 | |
fi | |
done | |
mv $BAK_PATH/`hostname`.sql $BAK_PATH/`hostname`.sql.1 2>&1 | |
mysqldump -u$SQL_USERNAME -p$SQL_PASS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on line 11 can we echo the ssh log to the email sent