Adjust script 'sync_databases_between_mysql_installations.sh'.

This commit is contained in:
2024-01-02 00:47:03 +01:00
parent 1ac27093e9
commit d7a10405ad
2 changed files with 464 additions and 1 deletions

View File

@@ -25,7 +25,20 @@ mkdir -p ${log_dir}
# - ...
# - "
# -
sync_mysql_databases="ALL"
sync_mysql_databases="
akb_br
b_asyl_barnim
brandenburg33
demos_g_nazis
gallery_akb
kurage
neuruppin
phpmyadmin
rundertisch
soli_asyl_potsdam
willkommen_ohv
zossen
"
# - mysql_source_credential_args
# - mysql_target_credential_args
@@ -249,6 +262,43 @@ if $_got_mysql_databases ; then
fi
# - GET current (global) value for 'unique_checks'
# -
echononl " GET current (global) 'unique_checks' value"
CUR_UNIQUE_CHECKS="$(${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SHOW GLOBAL VARIABLES LIKE 'unique_checks'" | awk '{print$2}')" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - GET current (global) value for 'foreign_key_checks'
# -
echononl " GET current (global) 'foreign_key_checks' value"
CUR_FOREIGN_KEY_CHECKS="$(${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SHOW GLOBAL VARIABLES LIKE 'foreign_key_checks'" | awk '{print$2}')" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - GET current (global) value for 'innodb_flush_log_at_trx_commit'
# -
echononl " GET current (global) 'innodb_flush_log_at_trx_commit' value"
CUR_INNODB_FLUSH_LOG_AT_TRX_COMMIT="$(${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SHOW GLOBAL VARIABLES LIKE 'innodb_flush_log_at_trx_commit'" | awk '{print$2}')" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
echo ""
# - Set Autocommit OFF
# -
echononl " Set Autocommit to OFF"
@@ -260,8 +310,45 @@ if $_got_mysql_databases ; then
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Set UNIQUE_CHECKS OFF
# -
echononl " Set 'unique_checks' to OFF"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL unique_checks='OFF'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Set FOREIGN_KEY_CHECKS OFF
# -
echononl " Set 'foreign_key_checks' to OFF"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL foreign_key_checks='OFF'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Set innodb_flush_log_at_trx_commit OFF
# -
echononl " Set 'innodb_flush_log_at_trx_commit' to 2"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL innodb_flush_log_at_trx_commit=2" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
echo ""
for _val in $_mysql_databases_remote ; do
IFS=':' read -a _val_arr <<< "${_val}"
@@ -336,6 +423,39 @@ if $_got_mysql_databases ; then
error "$(cat $tmp_err_msg)"
fi
# - Reset (global) value for 'unique_checks'
# -
echononl " Reset (global) 'unique_checks' value to '$CUR_UNIQUE_CHECKS'"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL unique_checks='$CUR_UNIQUE_CHECKS'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Reset (global) value for 'foreign_key_checks'
# -
echononl " Reset (global) 'foreign_key_checks' value to '$CUR_FOREIGN_KEY_CHECKS'"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL foreign_key_checks='$CUR_FOREIGN_KEY_CHECKS'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Reset (global) value for 'innodb_flush_log_at_trx_commit'
# -
echononl " Reset (global) 'innodb_flush_log_at_trx_commit' value to '$CUR_INNODB_FLUSH_LOG_AT_TRX_COMMIT'"
${mysql_target_exe} ${mysql_target_credential_args} -N -s -e "SET GLOBAL innodb_flush_log_at_trx_commit=$CUR_INNODB_FLUSH_LOG_AT_TRX_COMMIT" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
fi
rm $tmp_err_msg