Skip to content

Instantly share code, notes, and snippets.

@bleepbloop
Created February 24, 2011 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleepbloop/841538 to your computer and use it in GitHub Desktop.
Save bleepbloop/841538 to your computer and use it in GitHub Desktop.
main decision tree of SQL cron
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
@bleepbloop
Copy link
Author

on line 11 can we echo the ssh log to the email sent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment