#!/bin/bash export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CONFIG_FILE=$DIR/config.sh [[ ! -r "${CONFIG_FILE}" ]] && { echo "Could not read ${CONFIG_FILE}!"; exit 1; } set -a . "${CONFIG_FILE}" set +a echo "Stop local slave" > $log_file mysql --defaults-extra-file=./.my.cnf -e "STOP SLAVE;" #Started line on execute remote sql on remote server echo "Start execution all commands on remote server" >> $log_file REMOTE_SQL= for i in ${databases[@]} do REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;' done REMOTE_SQL=$REMOTE_SQL' system ./_activate-slave.sh; system ./_dump.sh;' for i in ${databases[@]} do REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;' done mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL" echo "Start local slave" >> $log_file mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;" if [[ "$1" = "master-to-master" ]]; then ./replication-master-to-master.sh; fi