sync_from_old_server.sh: replace 'mysql_credential_args' with 'mysql_remote_credential_args' and 'mysql_local_credential_args'.
This commit is contained in:
parent
f32a8e1369
commit
0d891f7c88
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
ipv4_old="83.223.86.98"
|
ipv4_old="<old-ipv4-address>"
|
||||||
old_server_ip=$ipv4_old
|
old_server_ip=$ipv4_old
|
||||||
|
|
||||||
tmp_err_msg=$(mktemp)
|
tmp_err_msg=$(mktemp)
|
||||||
@ -14,7 +14,7 @@ log_dir=/root/sync_from_old_server_logs
|
|||||||
# /data/home/max
|
# /data/home/max
|
||||||
#"
|
#"
|
||||||
sync_home_dirs="
|
sync_home_dirs="
|
||||||
/home/ilker
|
/home/confluence
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
@ -40,28 +40,24 @@ sync_home_dirs="
|
|||||||
# - /home/chris
|
# - /home/chris
|
||||||
# - "
|
# - "
|
||||||
# -
|
# -
|
||||||
sync_web_dirs="
|
sync_web_dirs=""
|
||||||
"
|
|
||||||
|
|
||||||
|
|
||||||
# - Sync Apache virtual host configurations
|
# - Sync Apache virtual host configurations
|
||||||
# -
|
# -
|
||||||
# - Note:
|
# - Note:
|
||||||
# -
|
# -
|
||||||
sync_vhost_dirs="
|
sync_vhost_dirs=""
|
||||||
/usr/local/apache2/conf/vhosts
|
|
||||||
"
|
|
||||||
|
|
||||||
# - Only needed to replace ip-addresse in virtual host configuration files
|
# - Only needed to replace ip-addresse in virtual host configuration files
|
||||||
# -
|
# -
|
||||||
ipv4_new="162.55.82.78"
|
ipv4_new="<new-ipv4-address>"
|
||||||
ipv6_old="2a01:30:0:13:211:84ff:feb7:7f9c"
|
ipv6_old="<old-ipv6-address>"
|
||||||
ipv6_new="2a01:4f8:271:1266::78"
|
ipv6_new="<new-ipv6-address>"
|
||||||
|
|
||||||
|
|
||||||
# - Sync dehydrated cert directory
|
# - Sync dehydrated cert directory
|
||||||
# -
|
# -
|
||||||
sync_dehydrated_dirs=""
|
|
||||||
sync_dehydrated_dirs="
|
sync_dehydrated_dirs="
|
||||||
/var/lib/dehydrated/certs
|
/var/lib/dehydrated/certs
|
||||||
"
|
"
|
||||||
@ -85,13 +81,13 @@ sync_dehydrated_dirs="
|
|||||||
# -
|
# -
|
||||||
sync_other_dirs="
|
sync_other_dirs="
|
||||||
/root/bin/mysql/databases
|
/root/bin/mysql/databases
|
||||||
/usr/local/webalizer/etc
|
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
# - Sync files
|
# - Sync files
|
||||||
# -
|
# -
|
||||||
sync_files="
|
sync_files="
|
||||||
|
/var/lib/dehydrated/domains.txt
|
||||||
/etc/pure-ftpd/pureftpd.passwd
|
/etc/pure-ftpd/pureftpd.passwd
|
||||||
"
|
"
|
||||||
|
|
||||||
@ -121,15 +117,17 @@ sync_pgsql_databases=""
|
|||||||
# -
|
# -
|
||||||
sync_mysql_databases="ALL"
|
sync_mysql_databases="ALL"
|
||||||
|
|
||||||
# - mysql_credential_args
|
# - mysql_remote_credential_args
|
||||||
|
# - mysql_local_credential_args
|
||||||
# -
|
# -
|
||||||
# - Example
|
# - Example
|
||||||
|
# - mysql_credential_args="-u root -S /run/mysqld/mysqld.sock"
|
||||||
# - mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf"
|
# - mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf"
|
||||||
# - 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_credential_args="--login-path=local"
|
mysql_remote_credential_args="--login-path=local"
|
||||||
|
mysql_local_credential_args="-u root -S /run/mysqld/mysqld.sock"
|
||||||
|
|
||||||
# -------------
|
# -------------
|
||||||
# --- Some functions
|
# --- Some functions
|
||||||
@ -317,7 +315,7 @@ 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 [[ "$sync_mysql_databases" = "ALL" ]]; then
|
||||||
echononl " Get MySQL databases from $old_server_ip.."
|
echononl " Get MySQL databases from $old_server_ip.."
|
||||||
_mysql_databases_remote=$(ssh $old_server_ip "/usr/local/mysql/bin/mysql $mysql_credential_args -N -s -e \"show databases\"")
|
_mysql_databases_remote=$(ssh $old_server_ip "/usr/local/mysql/bin/mysql $mysql_remote_credential_args -N -s -e \"show databases\"")
|
||||||
if [[ $? -eq 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
echo_ok
|
echo_ok
|
||||||
_got_mysql_databases=true
|
_got_mysql_databases=true
|
||||||
@ -338,7 +336,7 @@ if $_got_mysql_databases ; then
|
|||||||
# - GET current (global) Autocommit value
|
# - GET current (global) Autocommit value
|
||||||
# -
|
# -
|
||||||
echononl " GET current (global) Autocommit value"
|
echononl " GET current (global) Autocommit value"
|
||||||
CUR_AUTOCOMMIT="$(/usr/local/mysql/bin/mysql $mysql_credential_args -N -s -e "SHOW GLOBAL VARIABLES LIKE 'autocommit'" | awk '{print$2}')" >> $log_file 2> $tmp_err_msg
|
CUR_AUTOCOMMIT="$(mysql $mysql_local_credential_args -N -s -e "SHOW GLOBAL VARIABLES LIKE 'autocommit'" | awk '{print$2}')" >> $log_file 2> $tmp_err_msg
|
||||||
if [[ $? -eq 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
@ -350,7 +348,7 @@ if $_got_mysql_databases ; then
|
|||||||
# - Set Autocommit OFF
|
# - Set Autocommit OFF
|
||||||
# -
|
# -
|
||||||
echononl " Set Autocommit to OFF"
|
echononl " Set Autocommit to OFF"
|
||||||
mysql $mysql_credential_args -N -s -e "SET GLOBAL AUTOCOMMIT='OFF'" >> $log_file 2> $tmp_err_msg
|
mysql $mysql_local_credential_args -N -s -e "SET GLOBAL AUTOCOMMIT='OFF'" >> $log_file 2> $tmp_err_msg
|
||||||
if [[ $? -eq 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
@ -391,7 +389,7 @@ if $_got_mysql_databases ; then
|
|||||||
echo_skipped
|
echo_skipped
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
ssh $old_server_ip "/usr/local/mysql/bin/mysqldump $mysql_credential_args $_src_db" | mysql $mysql_credential_args $_dst_db >> $log_file 2> $tmp_err_msg
|
ssh $old_server_ip "/usr/local/mysql/bin/mysqldump $mysql_remote_credential_args $_src_db" | mysql $mysql_local_credential_args $_dst_db >> $log_file 2> $tmp_err_msg
|
||||||
if [[ $? -eq 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
@ -405,7 +403,7 @@ if $_got_mysql_databases ; then
|
|||||||
# -
|
# -
|
||||||
echo ""
|
echo ""
|
||||||
echononl " Reset (global) Autocommit value to '$CUR_AUTOCOMMIT'"
|
echononl " Reset (global) Autocommit value to '$CUR_AUTOCOMMIT'"
|
||||||
mysql $mysql_credential_args -N -s -e "SET GLOBAL AUTOCOMMIT='$CUR_AUTOCOMMIT'" >> $log_file 2> $tmp_err_msg
|
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
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user