From: Alexander Barton Date: Wed, 2 Sep 2015 10:10:19 +0000 (+0200) Subject: Check if SQL slave status is OK before dumping databases X-Git-Url: https://arthur.barton.de/gitweb/?p=MkMySqlDump.git;a=commitdiff_plain;h=6d4fff4691750ed8897005aa6a43fd5194c0b887 Check if SQL slave status is OK before dumping databases --- diff --git a/bin/mkmysqldump b/bin/mkmysqldump index 15d6657..ed9c5ac 100755 --- a/bin/mkmysqldump +++ b/bin/mkmysqldump @@ -134,6 +134,21 @@ if [ $? -ne 0 ]; then exit 1 fi +echo "Checking slave status ..." +Slave_IO_Running=""; Slave_SQL_Running="" +eval "$(echo 'SHOW SLAVE STATUS\G' | mysql | sed -n '/Running/p' | sed 's/: /=/g')" +if [ -n "$Slave_IO_Running" -o -n "$Slave_SQL_Running" ]; then + if [ "$Slave_IO_Running" = "Yes" -a "$Slave_SQL_Running" = "Yes" ]; then + echo "Server is running as MySQL slave, replication is Ok." + else + echo "Server is running as MySQL slave, but replication FAILED!" + ErrorNotice + exit 1 + fi +else + echo "Server is not running as MySQL slave. Ok." +fi + echo "Will dump the following databases:" for d in $DATABASES; do echo " - $d"