Comprehensive data protection for all workloads
Post Reply
adam900331
Veteran
Posts: 304
Liked: 22 times
Joined: Dec 01, 2019 7:27 pm
Contact:

Pre-freeze script (mysqldump) not working

Post by adam900331 »

Hy!

I would like to try the prefreeze script (database dump) with this file:
https://github.com/VeeamHub/application ... dumppre.sh

I modified the authentication method, so I use this mode:

Code: Select all

use_credentials="-u Admin -p password"
#defaults_file="/etc/my.cnf"
When I run manually (to try) on Linux, no error message appear on console, I run the script with this method:

Code: Select all

chmod +x ./pre-freeze_hot_online.sh
sudo ./pre-freeze_hot_online.sh
After the script running, I checked the log, where the script logging (/var/log/syslog), and I see the following:

Code: Select all

Oct 24 10:44:21 tst admin: ./pre-freeze_hot_online.sh executing mysqldump
Oct 24 10:44:21 tst admin: ./pre-freeze_hot_online.sh : mysqldump failed
Meanwhile the mysql_dump.sql file is empty, not generated any sql data.

What should be wrong?

Thanks.
HannesK
Product Manager
Posts: 14322
Liked: 2890 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Pre-freeze script (mysqldump) not working

Post by HannesK »

Hello,
my guess is sudo / permissions.

If that's no the case and nothing else can be found in the Logs on the Linux side, please check with Veeam support and post the support case number for reference.

Best regards,
Hannes
adam900331
Veteran
Posts: 304
Liked: 22 times
Joined: Dec 01, 2019 7:27 pm
Contact:

Re: Pre-freeze script (mysqldump) not working

Post by adam900331 »

I created a new account which has full access to databases, and the mysqldump failed error is still being.
I created the user with this mysql command:
CREATE USER 'test'@'localhost' IDENTIFIED BY 'password';

Grant all:
GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;

And after I give this account to the script:
use_credentials="-u test -p password"
adam900331
Veteran
Posts: 304
Liked: 22 times
Joined: Dec 01, 2019 7:27 pm
Contact:

Re: Pre-freeze script (mysqldump) not working

Post by adam900331 » 1 person likes this post

Hy!

It was hard, but solved the script problem. I had to create the credential file in another way, so I share my experience. The basic script that I use, yo can find in this github link:
Pre-freeze: https://github.com/VeeamHub/application ... dumppre.sh
Post-thaw: https://github.com/VeeamHub/application ... umppost.sh

I didn't find any information about the file which has contain the credential that can access the mysql databases. This whitepaper has some tip:
https://www.veeam.com/wp-consistent-pro ... riadb.html

You can find that use a file in /etc/my.cnf which contain the following data:

Code: Select all

[client]
user = user
password = Password
port = 3306
socket = /var/lib/mysql/mysql.sock
So, it is not work for me! I searched a lot on the internet (I am not Linux guru), and find an another solution. Created a new file int /etc/mysql/mysqlpass.cnf file which contain only the following data:

Code: Select all

[mysqldump]
user=admin
password=password
I modified the credential file path to /etc/mysql/mysqlpass.cnf:

Code: Select all

#!/bin/bash

# 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="-uroot -p"
defaults_file="/etc/mysql/mysqlpass.cnf"
dump_file="/tmp/mysql_dump.sql"
database="--all-databases"

sleep 10

if [ -f $defaults_file ]
then
	opts="--defaults-file=$defaults_file"
elif [ -n $use_credentials ]
then
	opts="$opts $use_credentials"
else
	echo "$0 : error, no mysql authentication method set" | logger
	exit 1
fi

opts="$opts $database"

echo "$0 executing mysqldump" | logger
mysqldump $opts >$dump_file 2>/dev/null
if [ $? -ne 0 ]
then
	echo "$0 : mysqldump failed" | logger
	exit 2
else
	echo "$0 : mysqldump suceeded" | logger
	sync;sync
fi
You don't have to modify nothing in post-thaw script:

Code: Select all

#!/bin/bash

dump_file="/tmp/mysql_dump.sql"

if [ -f $dump_file ]
then
        echo "$0 deleting mysql dump file $dump_file" | logger
        rm -f $dump_file > /dev/null 2>&1
        exit 0
else
        echo "$0 could not locate mysql dump file  $dump_file" | logger
        exit 1
fi
Successfully run the backup job:
https://ibb.co/PCRkcb4

You can check, during the pr-freeze script running, the mysql_dump.sql file size is growing in /tmp folder (so the mysqldump works):
https://ibb.co/F0TcjM5

When the post-thaw script ran, the mysql_dump.sql will be removed.


Also you can check in the Linux guest OS log file: /var/log/syslog

Code: Select all

Oct 28 15:54:28 server srvadmin: /tmp/ef4ecd30-3a73-4106-8285-783aea5cb4a3_pre-freeze_hot_online_no_credetial.sh executing mysqldump
Oct 28 15:56:06 server srvadmin: /tmp/ef4ecd30-3a73-4106-8285-783aea5cb4a3_pre-freeze_hot_online_no_credetial.sh : mysqldump suceeded
Oct 28 15:56:14 serversrvadmin: /tmp/cb202cf9-bac5-4257-9680-adcd88a343be_post-thaw_hot_online.sh deleting mysql dump file /tmp/mysql_dump.sql
I hope I helped with this solution. :)

Thanks.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 122 guests