]> arthur.barton.de Git - MkMySqlDump.git/commitdiff
Check if SQL slave status is OK before dumping databases
authorAlexander Barton <alex@barton.de>
Wed, 2 Sep 2015 10:10:19 +0000 (12:10 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 2 Sep 2015 10:10:19 +0000 (12:10 +0200)
bin/mkmysqldump

index 15d6657341671314e6e49beb22d2afcc099a1ce8..ed9c5ac51179be39a2250da9cd48cd113e55bfbb 100755 (executable)
@@ -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"