From 6d4fff4691750ed8897005aa6a43fd5194c0b887 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 2 Sep 2015 12:10:19 +0200 Subject: [PATCH] Check if SQL slave status is OK before dumping databases --- bin/mkmysqldump | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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" -- 2.39.2