We are having troubles with the MySQL/MariaDB Script.
We followed the instructions on the Veeam White Paper form: https://www.veeam.com/wp-consistent-pro ... riadb.html
We are using the Hot backup – Database freezing method with the following Scripts.
Please note, we slightly modified the script with the –h option at the mysql command as we are connecting with SSL and need to connect with the hostname instead of localhost. The connection works fine, this isn’t a problem.
Pre-freeze script:
Code: Select all
#!/bin/bash -xv
# config:
# when running on debian we can use existing debian-sys-maint account using defaults file
# otherwise, specify username and password below using use_credentials
#use_credentials="-u root -p"
#defaults_file="/etc/my.cnf"
defaults_file="/etc/my.cnf.d/veeambackup-client.cnf"
timeout=300
lock_file=/tmp/mysql_tables_read_lock
###
if [ -f $defaults_file ]; then
opts="--defaults-file=$defaults_file"
fi
if [ -n $use_credentials ]; then
opts="$opts $use_credentials"
fi
sleep_time=$((timeout+10))
rm -f $lock_file
echo "$0 executing FLUSH TABLES WITH READ LOCK" | logger
mysql $opts -h "HOSTNAME.DOMAIN.EXAMPLE" --execute="FLUSH TABLES WITH READ LOCK; system touch $lock_file; system nohup sleep $sleep_time; system echo\ lock released|logger;" > /dev/null & mysql_pid=$!
echo "$0 child pid $mysql_pid" | logger
c=0
while [ ! -f $lock_file ]
do
# check if mysql is running
if ! ps -p $mysql_pid 1>/dev/null; then
echo "$0 mysql command has failed (bad credentials?)" | logger
exit 1
fi
sleep 1
c=$((c+1))
if [ $c -gt $timeout ]; then
echo "$0 timed out waiting for lock" | logger
touch $lock_file
kill $mysql_pid
fi
done
echo $mysql_pid > $lock_file
exit 0
Code: Select all
#!/bin/bash -xv
lock_file=/tmp/mysql_tables_read_lock
###
mysql_pid=$(cat $lock_file)
echo "$0 sending sigterm to $mysql_pid" | logger
pkill -9 -P $mysql_pid
rm -f $lock_file
exit 0
Code: Select all
#!/bin/bash -xv
lock_file=/tmp/mysql_tables_read_lock
+ lock_file=/tmp/mysql_tables_read_lock
###
mysql_pid=$(cat $lock_file)
++ cat /tmp/mysql_tables_read_lock
+ mysql_pid=14023
echo "$0 sending sigterm to $mysql_pid" | logger
+ echo './post-thaw_mysqldump-script.sh sending sigterm to 14023'
+ logger
pkill -9 -P $mysql_pid
+ pkill -9 -P 14023
ERROR at line 1: Unknown command '\ '.
rm -f $lock_file
+ rm -f /tmp/mysql_tables_read_lock
exit 0
+ exit 0
mysql $opts -h " HOSTNAME.DOMAIN.EXAMPLE " --execute="FLUSH TABLES WITH READ LOCK; system touch $lock_file; system nohup sleep $sleep_time; system echo\ lock released|logger;" > /dev/null & mysql_pid=$!
If we were to omit the backslash after echo and just leave the line as followed, we wouldn’t get an error:
mysql $opts -h " HOSTNAME.DOMAIN.EXAMPLE " --execute="FLUSH TABLES WITH READ LOCK; system touch $lock_file; system nohup sleep $sleep_time; system echo lock released|logger;" > /dev/null & mysql_pid=$!
Question:
Is there a typo in the white paper and shouldn’t there be a backslash after the echo command? So the command would look like:
… system echo lock released|logger; …
What’s the purpose of the command if the backslash is needed?
… system echo\ lock released|logger; …
How can we fix the issue if the backslash is needed?
System:
CentOS Linux release 7.4.1708 (core) (Compatibility: ESXi 6.5 and higher (VM-Version 13))
MariaDB 5.5.56
Hypervisor: VMware ESXi 6.5.0 Build 7119157