sync_databases_between_mysql_installations.sh: fix error in case of all database sync.

This commit is contained in:
Christoph 2024-03-19 12:58:25 +01:00
parent fe539c14aa
commit bb4d5b5030

View File

@ -25,20 +25,7 @@ mkdir -p ${log_dir}
# - ... # - ...
# - " # - "
# - # -
sync_mysql_databases=" 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_source_credential_args
# - mysql_target_credential_args # - mysql_target_credential_args
@ -134,6 +121,13 @@ echo_skipped() {
echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]" echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]"
} }
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
service_exists() { service_exists() {
local n=$1 local n=$1
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | cut -f1 -d' ') == $n.service ]]; then if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | cut -f1 -d' ') == $n.service ]]; then
@ -230,7 +224,7 @@ sync_mysql_databases="${sync_mysql_databases%%*( )}"
if [[ -z "$sync_mysql_databases" ]]; then if [[ -z "$sync_mysql_databases" ]]; then
warn "No MySQL databases for syncing configured." warn "No MySQL databases for syncing configured."
elif [[ "$sync_mysql_databases" = "ALL" ]]; then elif [[ "$(trim "${sync_mysql_databases}")" = "ALL" ]]; then
echononl " Get MySQL databases from source Installation.." echononl " Get MySQL databases from source Installation.."
_mysql_databases_remote="$(${mysql_source_exe} ${mysql_source_credential_args} -N -s -e "show databases" 2> /dev/null)" _mysql_databases_remote="$(${mysql_source_exe} ${mysql_source_credential_args} -N -s -e "show databases" 2> /dev/null)"
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then