hosts/scripts/mysql_backup.sh: fix error if saving database mysql ('--lock-tables=0) in case of mariadb.

This commit is contained in:
Christoph 2019-01-29 16:38:55 +01:00
parent d57237eec7
commit 7013d8644f
2 changed files with 24 additions and 7 deletions

View File

@ -95,12 +95,6 @@ err_Log=${LOCK_DIR}/mysql.err.log
# -------------------- Variable --------------------- #
#
if [[ -n ${mysql_version} ]]; then
_backupDestArchiveDir="${script_backup_dir}/MySQL-${mysql_version}"
else
_backupDestArchiveDir="${script_backup_dir}/MySQL"
fi
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
mysql=`$ssh ${ssh_user}@$srcHost which mysql`
@ -152,6 +146,12 @@ else
MYSQL_DISTRIBUTION="MySQL"
fi
if [[ -n ${mysql_version} ]]; then
_backupDestArchiveDir="${script_backup_dir}/${MYSQL_DISTRIBUTION}-${mysql_version}"
else
_backupDestArchiveDir="${script_backup_dir}/${MYSQL_DISTRIBUTION}"
fi
if [ ! -d $_backupDestArchiveDir ]; then
@ -967,6 +967,15 @@ if $ARCHIVE ;then
mysqldump_flags="--no-data --no-create-info --routines"
if [ "$i" = "mysql" -a "$MYSQL_DISTRIBUTION" = "MariaDB" ]; then
# - prevent from error:
# - Error 1556: You can't use locks with log tables
# -
# - use '--lock-tables=0'
# -
mysqldump_flags="$mysqldump_flags --lock-tables=0"
fi
info_msg="save functions of database $i.."
echononl "\t$info_msg"
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
@ -1103,6 +1112,15 @@ if $ARCHIVE ;then
mysqldump_flags="$mysqldump_flags --events"
fi
if [ "$i" = "mysql" -a "$MYSQL_DISTRIBUTION" = "MariaDB" ]; then
# - prevent from error:
# - Error 1556: You can't use locks with log tables
# -
# - use '--lock-tables=0'
# -
mysqldump_flags="$mysqldump_flags --events --lock-tables=0"
fi
info_msg="save database $i.."
echononl "\t$info_msg"
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then

View File

@ -237,7 +237,6 @@ fi
## -
if $manual ; then
host_scripts="${hosts_base_dir}/localhost.sh"
host_scripts="${hosts_base_dir}/gw-km.anw-km.netz.sh"
else
host_scripts=`$find $hosts_base_dir -maxdepth 1 -type f -perm -700 | $sort`
fi