diff --git a/restore-mysql-daily b/restore-mysql-daily index cab4427..f4444c6 100644 --- a/restore-mysql-daily +++ b/restore-mysql-daily @@ -177,21 +177,18 @@ else echo "full restorion selected: comparisons will not be made, all non-excluded databases will be restored" fi -echo "\nfinding files in '$NEWPATH*.gz'" +echo -e "\nfinding files in '$NEWPATH*.gz'" for FILE in $NEWPATH*.gz; do STARTLOOP=$(date +%s) FILE=$(basename $FILE) echo -e "\n$(date +%F\ %T) | $FILE:" - if [[ "${SETPOSDB}" =~ ${FILE%%.*} ]]; then echo -e "\t-- recognized $FILE for master position and log file" - SETPOSFILE=$(realpath $FILE) + if [[ "${SETPOSDB}" =~ ${FILE%%.*} ]]; then echo -e "\t-- recognized '$FILE' for master position and log file" + SETPOSFILE=$NEWPATH$FILE SETPOSSTMT=$(zcat $SETPOSFILE | head -40 | grep MASTER | sed 's/-- //') - echo -e "\n$SETPOSSTMT\n" - exit 2 + echo -e "\t$SETPOSSTMT" fi - exit 1 - if [[ "${SKIPDBS[*]}" =~ ${FILE%%.*} ]]; then echo -e "\t-- skipping $FILE";continue; fi; if [[ FULLRESTORE == false ]]; then @@ -216,18 +213,18 @@ for FILE in $NEWPATH*.gz; do printf '\t%02dh:%02dm:%02ds\n' $((EXCTIME/3600)) $((EXCTIME%3600/60)) $((EXCTIME%60)) done -if [[ -n MASTER_HOST ]] && [[ -n MASTER_USER ]] && [[ -n MASTER_PASSWORD ]]; then - echo -e "applying configuration for replication\n\thost: $MASTER_HOST\n\tuser: $MASTER_USER" +if [[ $MASTER_HOST && $MASTER_USER && $MASTER_PASSWORD ]]; then + echo -e "\napplying configuration for replication\n\thost: $MASTER_HOST\n\tuser: $MASTER_USER" $CMD mysql -e "CHANGE MASTER TO master_host='$MASTER_HOST',master_user='$MASTER_USER',master_password='$MASTER_PASSWORD';" else - echo "replication credentials not configured" + echo "\nreplication credentials not configured" fi -if [[ -n $SETPOSSTMT ]]; then - $CMD mysql -e "$SETPOS" +if [[ $SETPOSSTMT ]]; then + $CMD mysql -e "$SETPOSSTMT" else DONOTSTART=true - echo "master position database undefined, listing suggestions" + echo "\nmaster position database undefined, listing suggestions" for FILE in $NEWPATH*.gz; do echo $(basename $FILE) echo -e "\t$(zcat $FILE | head -40 | grep MASTER)"