sync_from_old_server.sh: add functionality for calling as cronjob.

This commit is contained in:
Christoph 2024-01-31 12:39:51 +01:00
parent d7a10405ad
commit 80656a8269
3 changed files with 1321 additions and 110 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@
# give old IPv4 address here - its mandatory" # give old IPv4 address here - its mandatory"
# #
ipv4_old="" ipv4_old="<SRC-IP_ADDRESS>"
old_server_ip=$ipv4_old old_server_ip=$ipv4_old
tmp_err_msg=$(mktemp) tmp_err_msg=$(mktemp)
@ -80,6 +80,14 @@ sync_dehydrated_dirs=""
# - ... # - ...
# - " # - "
# - # -
# - Examples:
# -
# - sync_other_dirs="
# - /etc/cron.d:/data/old-server/etc/cron.d
# - /opt:/data/old-server/opt
# - /root/crontab
# - /usr/local/bin
# - "
# - # -
# - Note: # - Note:
# - the basename of the destination directory must be the same as # - the basename of the destination directory must be the same as
@ -128,66 +136,123 @@ sync_mysql_databases=""
# - mysql_credential_args="--login-path=local" # - mysql_credential_args="--login-path=local"
# - mysql_credential_args="-u <db_name> -p'<db_passwd>'" # - mysql_credential_args="-u <db_name> -p'<db_passwd>'"
# - # -
mysql_remote_credential_args="" mysql_remote_credential_args="--login-path=local"
mysql_local_credential_args="" mysql_local_credential_args="-S /run/mysqld/mysqld.sock"
# ------------- # -------------
# --- Some functions # --- Some functions
# ------------- # -------------
clean_up() {
# Perform program exit housekeeping
#rm -rf "$LOCK_DIR"
rm $tmp_err_msg
blank_line
exit $1
}
echononl(){ echononl(){
echo X\\c > /tmp/shprompt$$ if $terminal ; then
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then echo X\\c > /tmp/shprompt$$
echo -e -n "$*\\c" 1>&2 if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
else echo -e -n "$*\\c" 1>&2
echo -e -n "$*" 1>&2 else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
fi fi
rm /tmp/shprompt$$
} }
fatal(){ fatal(){
echo "" echo ""
echo -e "fatal error: $*" if $terminal ; then
echo -e " [ \033[31m\033[1mFatal\033[m ]: $*"
echo ""
echo -e " \033[31m\033[1mScript was interupted\033[m!"
else
echo " [ Fatal ]: $*"
echo ""
echo " Script was terminated...."
fi
echo "" echo ""
echo -e "\t\033[31m\033[1mInstalllation will be interrupted\033[m\033[m" clean_up 1
echo ""
exit 1
} }
error(){ error(){
echo "" echo ""
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*" if $terminal ; then
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
else
echo "[ Error ]: $*"
fi
echo "" echo ""
} }
warn (){ warn (){
echo "" echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" if $terminal ; then
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
else
echo "[ Warning ]: $*"
fi
echo "" echo ""
} }
warn_only_terminal () {
if $terminal ; then
echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
fi
}
info (){ info (){
echo "" if $terminal ; then
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" echo ""
echo "" echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
fi
} }
echo_done() { echo_done() {
echo -e "\033[80G[ \033[32mdone\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[32mdone\033[m ]"
fi
} }
echo_ok() { echo_ok() {
echo -e "\033[80G[ \033[32mok\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[32mok\033[m ]"
fi
} }
echo_ok() { echo_ok() {
echo -e "\033[80G[ \033[32mok\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[32mok\033[m ]"
fi
} }
echo_warning() { echo_warning() {
echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]"
fi
} }
echo_failed(){ echo_failed(){
echo -e "\033[80G[ \033[1;31mfailed\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[1;31mfailed\033[m ]"
fi
} }
echo_skipped() { echo_skipped() {
echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]" if $terminal ; then
echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]"
fi
}
blank_line() {
if $terminal ; then
echo ""
fi
} }
detect_mysql_version () { detect_mysql_version () {
@ -207,34 +272,38 @@ detect_mysql_version () {
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mariadb- ]]; then elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mariadb- ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB" MYSQL_CUR_DISTRIBUTION="MariaDB"
else else
error "MySQL Instalation found, but cannot determin the distribution!" if $terminal ; then
error "MySQL Instalation found, but cannot determin the distribution!"
MYSQL_CUR_DISTRIBUTION= MYSQL_CUR_DISTRIBUTION=
echo "" echo ""
echo " Select the MySQL distribution to install." echo " Select the MySQL distribution to install."
echo "" echo ""
echo " [1] MySQL (the original community edition)" echo " [1] MySQL (the original community edition)"
echo " [2] Percona Server for MySQL" echo " [2] Percona Server for MySQL"
echo " [3] MariaDB" echo " [3] MariaDB"
echo "" echo ""
echononl " Eingabe [1/2/3]: " echononl " Eingabe [1/2/3]: "
while [ "$MYSQL_CUR_DISTRIBUTION" != "MySQL" -a "$MYSQL_CUR_DISTRIBUTION" != "MariaDB" -a "$MYSQL_CUR_DISTRIBUTION" != "Percona" ];do while [ "$MYSQL_CUR_DISTRIBUTION" != "MySQL" -a "$MYSQL_CUR_DISTRIBUTION" != "MariaDB" -a "$MYSQL_CUR_DISTRIBUTION" != "Percona" ];do
read OPTION read OPTION
case $OPTION in case $OPTION in
1) MYSQL_CUR_DISTRIBUTION="MySQL" 1) MYSQL_CUR_DISTRIBUTION="MySQL"
;; ;;
2) MYSQL_CUR_DISTRIBUTION="Percona" 2) MYSQL_CUR_DISTRIBUTION="Percona"
;; ;;
3) MYSQL_CUR_DISTRIBUTION="MariaDB" 3) MYSQL_CUR_DISTRIBUTION="MariaDB"
;; ;;
*) echo "" *) echo ""
echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]" echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]"
echo "" echo ""
echononl " Eingabe:" echononl " Eingabe:"
;; ;;
esac esac
done done
else
fatal "MySQL Instalation found, but cannot determin the distribution!"
fi
fi fi
MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)" MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)"
@ -255,6 +324,21 @@ service_exists() {
} }
# ----------
# - Some checks ..
# ----------
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
terminal=false
# ---------- # ----------
@ -273,7 +357,7 @@ else
systemd_exists=true systemd_exists=true
fi fi
echo "" blank_line
echononl " Test ssh connection to $old_server_ip" echononl " Test ssh connection to $old_server_ip"
@ -293,16 +377,21 @@ if [[ -f "/root/.ssh/config" ]] ; then
echo_ok echo_ok
else else
echo_failed echo_failed
error "$(cat $tmp_err_msg)"
echononl "continue anyway [yes/no]: " if $terminal ; then
read OK error "$(cat $tmp_err_msg)"
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do echononl "continue anyway [yes/no]: "
echononl "Wrong entry! - repeat [yes/no]: "
read OK read OK
done OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
[[ $OK = "yes" ]] || fatal "Interupted by user" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interupted by user"
else
fatal "$(cat $tmp_err_msg)"
fi
fi fi
else else
@ -324,16 +413,21 @@ if [[ $? -eq 0 ]];then
ssh_config_exists=true ssh_config_exists=true
else else
echo_failed echo_failed
error "$(cat $tmp_err_msg)"
echononl "continue anyway [yes/no]: " if $terminal ; then
read OK error "$(cat $tmp_err_msg)"
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do echononl "continue anyway [yes/no]: "
echononl "Wrong entry! - repeat [yes/no]: "
read OK read OK
done OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
[[ $OK = "yes" ]] || fatal "Interupted by user" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interupted by user"
else
fatal "$(cat $tmp_err_msg)"
fi
fi fi
@ -357,14 +451,16 @@ fi
# - Syncing PostgreSQL Databases.." # - Syncing PostgreSQL Databases.."
# - # -
echo -e "\n\n \033[37m\033[1mSyncing PostgreSQL Databases..\033[m\n" if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing PostgreSQL Databases..\033[m\n"
fi
_got_pgsql_databases=false _got_pgsql_databases=false
sync_pgsql_databases="${sync_pgsql_databases##*( )}" sync_pgsql_databases="${sync_pgsql_databases##*( )}"
sync_pgsql_databases="${sync_pgsql_databases%%*( )}" sync_pgsql_databases="${sync_pgsql_databases%%*( )}"
if [[ -z "$sync_pgsql_databases" ]]; then if [[ -z "$sync_pgsql_databases" ]]; then
warn "No PostgreSQL databases for syncing configured." warn_only_terminal "No PostgreSQL databases for syncing configured."
elif [[ "$sync_pgsql_databases" = "ALL" ]]; then elif [[ "$sync_pgsql_databases" = "ALL" ]]; then
echononl " Get (all) PostgreSQL databases from $old_server_ip.." echononl " Get (all) PostgreSQL databases from $old_server_ip.."
_psql_databases=$(ssh $old_server_ip "cd /tmp ; sudo -u postgres psql -lt" 2> $tmp_err_msg | grep -v -e"^$" | awk '{print$1}') _psql_databases=$(ssh $old_server_ip "cd /tmp ; sudo -u postgres psql -lt" 2> $tmp_err_msg | grep -v -e"^$" | awk '{print$1}')
@ -401,7 +497,7 @@ if $_got_pgsql_databases ; then
sudo=$(ssh $old_server_ip which sudo 2> /dev/null) sudo=$(ssh $old_server_ip which sudo 2> /dev/null)
su=$(ssh $old_server_ip which su 2> /dev/null) su=$(ssh $old_server_ip which su 2> /dev/null)
echo "" blank_line
for _db in $_pgsql_databases_remote ; do for _db in $_pgsql_databases_remote ; do
echononl " Sync Database '$_db'.." echononl " Sync Database '$_db'.."
if [[ "${_db}" = "template0" ]] || [[ "${_db}" = "template1" ]] || [[ "${_db}" = "postgres" ]]; then if [[ "${_db}" = "template0" ]] || [[ "${_db}" = "template1" ]] || [[ "${_db}" = "postgres" ]]; then
@ -429,10 +525,12 @@ fi
# - Syncing MySQL Databases.." # - Syncing MySQL Databases.."
# - # -
echo -e "\n\n \033[37m\033[1mSyncing MySQL Databases..\033[m\n" if $terminal; then
echo -e "\n\n \033[37m\033[1mSyncing MySQL Databases..\033[m\n"
fi
if [[ -z "$sync_mysql_databases" ]]; then if [[ -z "$sync_mysql_databases" ]]; then
warn "No MySQL databases for syncing configured." warn_only_terminal "No MySQL databases for syncing configured."
else else
detect_mysql_version detect_mysql_version
@ -542,7 +640,7 @@ if $_got_mysql_databases ; then
echo_failed echo_failed
error "$(cat $tmp_err_msg)" error "$(cat $tmp_err_msg)"
fi fi
echo "" blank_line
# - Set Autocommit OFF # - Set Autocommit OFF
@ -624,7 +722,7 @@ if $_got_mysql_databases ; then
continue continue
fi fi
echo "" blank_line
if [[ -n "${_val_arr[1]}" ]] ; then if [[ -n "${_val_arr[1]}" ]] ; then
echononl " Sync Database '$_src_db' --> '$_dst_db'.. " echononl " Sync Database '$_src_db' --> '$_dst_db'.. "
else else
@ -638,7 +736,9 @@ if $_got_mysql_databases ; then
echo_failed echo_failed
error "$(cat $tmp_err_msg)" error "$(cat $tmp_err_msg)"
echo -e "\n\n \033[33mSomething went wromg! I'm trying an alternative way ..\033[m\n" if $terminal ; then
echo -e "\n\n \033[33mSomething went wromg! I'm trying an alternative way ..\033[m\n"
fi
echononl " Read remote DB '${_src_db}' into local file '/tmp/${_dst_db}-${cur_date}.sql'.." echononl " Read remote DB '${_src_db}' into local file '/tmp/${_dst_db}-${cur_date}.sql'.."
@ -686,7 +786,7 @@ if $_got_mysql_databases ; then
# - Reset (global) Autocommit value # - Reset (global) Autocommit value
# - # -
echo "" blank_line
echononl " Reset (global) Autocommit value to '$CUR_AUTOCOMMIT'" echononl " Reset (global) Autocommit value to '$CUR_AUTOCOMMIT'"
${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL AUTOCOMMIT='$CUR_AUTOCOMMIT'" >> $log_file 2> $tmp_err_msg ${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL AUTOCOMMIT='$CUR_AUTOCOMMIT'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
@ -698,7 +798,7 @@ if $_got_mysql_databases ; then
# - Reset (global) value for 'unique_checks' # - Reset (global) value for 'unique_checks'
# - # -
echo "" blank_line
echononl " Reset (global) 'unique_checks' value to '$CUR_UNIQUE_CHECKS'" echononl " Reset (global) 'unique_checks' value to '$CUR_UNIQUE_CHECKS'"
${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL unique_checks='$CUR_UNIQUE_CHECKS'" >> $log_file 2> $tmp_err_msg ${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL unique_checks='$CUR_UNIQUE_CHECKS'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
@ -710,7 +810,7 @@ if $_got_mysql_databases ; then
# - Reset (global) value for 'foreign_key_checks' # - Reset (global) value for 'foreign_key_checks'
# - # -
echo "" blank_line
echononl " Reset (global) 'foreign_key_checks' value to '$CUR_FOREIGN_KEY_CHECKS'" echononl " Reset (global) 'foreign_key_checks' value to '$CUR_FOREIGN_KEY_CHECKS'"
${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL foreign_key_checks='$CUR_FOREIGN_KEY_CHECKS'" >> $log_file 2> $tmp_err_msg ${l_mysql} $mysql_local_credential_args -N -s -e "SET GLOBAL foreign_key_checks='$CUR_FOREIGN_KEY_CHECKS'" >> $log_file 2> $tmp_err_msg
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
@ -722,7 +822,7 @@ if $_got_mysql_databases ; then
# - Reset (global) value for 'innodb_flush_log_at_trx_commit' # - Reset (global) value for 'innodb_flush_log_at_trx_commit'
# - # -
echo "" blank_line
echononl " Reset (global) 'innodb_flush_log_at_trx_commit' value to '$CUR_INNODB_FLUSH_LOG_AT_TRX_COMMIT'" echononl " Reset (global) 'innodb_flush_log_at_trx_commit' value to '$CUR_INNODB_FLUSH_LOG_AT_TRX_COMMIT'"
${l_mysql} $mysql_local_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 ${l_mysql} $mysql_local_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 if [[ $? -eq 0 ]];then
@ -735,14 +835,15 @@ if $_got_mysql_databases ; then
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing Home Directories..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing Home Directories..\033[m\n"
fi
_got_home_dirs=false _got_home_dirs=false
sync_home_dirs="${sync_home_dirs##*( )}" sync_home_dirs="${sync_home_dirs##*( )}"
sync_home_dirs="${sync_home_dirs%%*( )}" sync_home_dirs="${sync_home_dirs%%*( )}"
if [[ -z "${sync_home_dirs,,}" ]] ; then if [[ -z "${sync_home_dirs,,}" ]] ; then
warn "No Home Directories for syncing configured" warn_only_terminal "No Home Directories for syncing configured"
else else
_got_home_dirs=true _got_home_dirs=true
fi fi
@ -762,15 +863,16 @@ if $_got_home_dirs ; then
done done
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing Files..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing Files..\033[m\n"
fi
_got_files=false _got_files=false
sync_files="${sync_files##*( )}" sync_files="${sync_files##*( )}"
sync_files="${sync_files%%*( )}" sync_files="${sync_files%%*( )}"
if [[ -z "${sync_files,,}" ]] ; then if [[ -z "${sync_files,,}" ]] ; then
warn "No Files for syncing configured" warn_only_terminal "No Files for syncing configured"
else else
_got_files=true _got_files=true
fi fi
@ -790,14 +892,15 @@ if $_got_files ; then
done done
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing Web Directories..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing Web Directories..\033[m\n"
fi
_got_web_dirs=false _got_web_dirs=false
sync_web_dirs="${sync_web_dirs##*( )}" sync_web_dirs="${sync_web_dirs##*( )}"
sync_web_dirs="${sync_web_dirs%%*( )}" sync_web_dirs="${sync_web_dirs%%*( )}"
if [[ -z "${sync_web_dirs,,}" ]] ; then if [[ -z "${sync_web_dirs,,}" ]] ; then
warn "No Web Directories for syncing configured" warn_only_terminal "No Web Directories for syncing configured"
else else
_got_web_dirs=true _got_web_dirs=true
fi fi
@ -811,8 +914,10 @@ if $_got_web_dirs ; then
_src_dir="${_val_arr[0]}" _src_dir="${_val_arr[0]}"
if [[ -n "${_val_arr[1]}" ]] ; then if [[ -n "${_val_arr[1]}" ]] ; then
_dst_dir="${_val_arr[1]}" _dst_dir="${_val_arr[1]}"
echo -e " Syncinc directory \"${_src_dir}\"" if $terminal ; then
echononl " --> ${_dst_dir} .." echo -e " Syncinc directory \"${_src_dir}\""
echononl " --> ${_dst_dir} .."
fi
else else
_dst_dir="$_src_dir" _dst_dir="$_src_dir"
echononl " Syncinc directory \"${_src_dir}\".." echononl " Syncinc directory \"${_src_dir}\".."
@ -837,14 +942,15 @@ fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing Vhost Configurations..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing Vhost Configurations..\033[m\n"
fi
_got_vhost_dirs=false _got_vhost_dirs=false
sync_vhost_dirs="${sync_vhost_dirs##*( )}" sync_vhost_dirs="${sync_vhost_dirs##*( )}"
sync_vhost_dirs="${sync_vhost_dirs%%*( )}" sync_vhost_dirs="${sync_vhost_dirs%%*( )}"
if [[ -z "${sync_vhost_dirs,,}" ]] ; then if [[ -z "${sync_vhost_dirs,,}" ]] ; then
warn "No Vhost Configurations for syncing configured" warn_only_terminal "No Vhost Configurations for syncing configured"
else else
_got_vhost_dirs=true _got_vhost_dirs=true
fi fi
@ -871,8 +977,9 @@ if $_got_vhost_dirs ; then
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mConvert IP's in Vhost Configurations..\033[m\n" echo -e "\n\n \033[37m\033[1mConvert IP's in Vhost Configurations..\033[m\n"
fi
if $_got_vhost_dirs ; then if $_got_vhost_dirs ; then
log_file=${log_dir}/convert_vhost_configs.log log_file=${log_dir}/convert_vhost_configs.log
@ -932,17 +1039,18 @@ if $_got_vhost_dirs ; then
fi fi
done done
else else
warn "No Vhost Configurations for syncing configured, so no IP conversion done.." warn_only_terminal "No Vhost Configurations for syncing configured, so no IP conversion done.."
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing Dehydrated Certs Dirs ..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing Dehydrated Certs Dirs ..\033[m\n"
fi
_got_dehydrated_dirs_dirs=false _got_dehydrated_dirs_dirs=false
sync_dehydrated_dirs="${sync_dehydrated_dirs##*( )}" sync_dehydrated_dirs="${sync_dehydrated_dirs##*( )}"
sync_dehydrated_dirs="${sync_dehydrated_dirs%%*( )}" sync_dehydrated_dirs="${sync_dehydrated_dirs%%*( )}"
if [[ -z "${sync_dehydrated_dirs,,}" ]] ; then if [[ -z "${sync_dehydrated_dirs,,}" ]] ; then
warn "No other Directories for syncing configured" warn_only_terminal "No dehydrated Directories for syncing configured"
else else
_got_dehydrated_dirs_dirs=true _got_dehydrated_dirs_dirs=true
fi fi
@ -962,14 +1070,15 @@ if $_got_dehydrated_dirs_dirs ; then
done done
fi fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mSyncing other Directories..\033[m\n" echo -e "\n\n \033[37m\033[1mSyncing other Directories..\033[m\n"
fi
_got_other_dirs=false _got_other_dirs=false
sync_other_dirs="${sync_other_dirs##*( )}" sync_other_dirs="${sync_other_dirs##*( )}"
sync_other_dirs="${sync_other_dirs%%*( )}" sync_other_dirs="${sync_other_dirs%%*( )}"
if [[ -z "${sync_other_dirs,,}" ]] ; then if [[ -z "${sync_other_dirs,,}" ]] ; then
warn "No other Directories for syncing configured" warn_only_terminal "No other Directories for syncing configured"
else else
_got_other_dirs=true _got_other_dirs=true
fi fi
@ -983,8 +1092,10 @@ if $_got_other_dirs ; then
_src_dir="${_val_arr[0]}" _src_dir="${_val_arr[0]}"
if [[ -n "${_val_arr[1]}" ]] ; then if [[ -n "${_val_arr[1]}" ]] ; then
_dst_dir="${_val_arr[1]}" _dst_dir="${_val_arr[1]}"
echo -e " Syncinc directory \"${_src_dir}\"" if $terminal ; then
echononl " --> ${_dst_dir} .." echo -e " Syncinc directory \"${_src_dir}\""
echononl " --> ${_dst_dir} .."
fi
else else
_dst_dir="$_src_dir" _dst_dir="$_src_dir"
echononl " Syncinc directory \"${_src_dir}\".." echononl " Syncinc directory \"${_src_dir}\".."
@ -1006,7 +1117,9 @@ if $_got_other_dirs ; then
done done
fi fi
echo -e "\n\n \033[37m\033[1mSome post syncing stuff..\033[m\n" if $terminal ; then
echo -e "\n\n \033[37m\033[1mSome post syncing stuff..\033[m\n"
fi
echononl " Recreate PureFTPd's password database" echononl " Recreate PureFTPd's password database"
if [[ -f "/etc/pure-ftpd/pureftpd.passwd" ]]; then if [[ -f "/etc/pure-ftpd/pureftpd.passwd" ]]; then
@ -1037,8 +1150,9 @@ fi
if $terminal ; then
echo -e "\n\n \033[37m\033[1mRestart Services..\033[m\n" echo -e "\n\n \033[37m\033[1mRestart Services..\033[m\n"
fi
echononl " (Re)start PureFTPd daemon (pure-ftpd)" echononl " (Re)start PureFTPd daemon (pure-ftpd)"
if $systemd_exists ; then if $systemd_exists ; then
@ -1094,6 +1208,4 @@ fi
rm $tmp_err_msg clean_up 0
echo ""
exit 0

1099
sync_from_old_server.sh.00 Executable file

File diff suppressed because it is too large Load Diff