Add support of databases from more than one MySQL installation.

This commit is contained in:
Christoph 2018-01-23 02:54:48 +01:00
parent e4d5f59252
commit 83bd3db9b9
5 changed files with 37 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.swp
/conf/logrotate.conf
/conf/rcopy.conf
/conf/*.key

View File

@ -98,12 +98,26 @@ mysql_backup=false
## - encrypted option file instead.
## -
## - 1.) Create (encrypted) option file:
## - $ mysql_config_editor set --login-path=local --socket=/var/run/mysqld/mysqld.sock --user=backup --password
## - $ Password:
## - $ mysql_config_editor set --login-path=local --socket=/tmp/mysql.sock --user=backup --password
## - $ Password:
## -
## - Its possible to hold more than one credentials in this (encrypted) option file:
## - $ mysql_config_editor set --login-path=local-5.6 --socket=/tmp/mysql-5.6.sock --user=backup --password
## -
## -
## - 2.) Set environment variable mysql_credential_args="--login-path=local"
## - Now, the backup script uses the encrypted option file instead of (unencrypt) password
## - on command line.
## -
## - You can backup databases from different mysql installations i.e. for a (main)
## - MySQL installation and a second one using variable 'mysql_credential_args_arr':
## -
## - mysql_credential_args_arr=("<Name1>:<MySQL credentials1>" ""<Name1>:<MySQL credentials2>" ...
## -
## - Example:
## - mysql_credential_args_arr=("5.7:--login-path=local" "5.6:--login-path=local-5.6")
## -
#mysql_credential_args_arr=""
mysql_credential_args="--login-path=local"
mysql_user=backup
mysql_password=backup

View File

@ -266,9 +266,24 @@ if [ "$found" = "true" -o "$pgsql_backup" = "true" -o "$mysql_backup" = "true"
$script_dir/svn_backup.sh
fi
if $mysql_backup ;then
echolog "\nGoing to backup mysql databases.. ( `$date +%H`:`$date +%M` h )"
export mysql_user mysql_password mysql_credential_args mysql_gzip
$script_dir/mysql_backup.sh
if [[ ${#mysql_credential_args_arr[@]} -gt 0 ]] ; then
for _val in "${mysql_credential_args_arr[@]}" ; do
IFS=':' read -a _val_arr <<< "${_val}"
mysql_version="${_val_arr[0]}"
mysql_credential_args="${_val_arr[1]}"
echolog "\nGoing to backup mysql databases ${_val_arr[0]} .. ( `$date +%H`:`$date +%M` h )"
export mysql_version mysql_credential_args mysql_gzip
$script_dir/mysql_backup.sh
done
else
echolog "\nGoing to backup mysql databases.. ( `$date +%H`:`$date +%M` h )"
export mysql_user mysql_password mysql_credential_args mysql_gzip
$script_dir/mysql_backup.sh
fi
## - !!
if $restart_apache ;then
$ssh ${ssh_user}@$srcHost "sudo /etc/init.d/apache2 restart"

View File

@ -74,7 +74,7 @@ err_Log=${LOCK_DIR}/mysql.err.log
# -------------------- Variable --------------------- #
#
_backupDestArchiveDir="${script_backup_dir}/MySQL"
_backupDestArchiveDir="${script_backup_dir}/MySQL-${mysql_version}"
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then

View File

@ -198,6 +198,7 @@ fi
## -
if $manual ; then
host_scripts="${hosts_base_dir}/localhost.sh"
host_scripts="${hosts_base_dir}/devel-php5.wf.netz.sh ${hosts_base_dir}/devel-db.wf.netz.sh"
else
host_scripts=`$find $hosts_base_dir -maxdepth 1 -type f -perm -700 | $sort`
fi