Host-based backup of VMware vSphere VMs.
Post Reply
adam900331
Veteran
Posts: 300
Liked: 22 times
Joined: Dec 01, 2019 7:27 pm
Contact:

Pre-freeze/post-thaw not working on Zabbix server

Post by adam900331 »

Hy!

I would like to backup in consistent state for my Zabbix server. I use this script for pre-freeze:
https://github.com/VeeamHub/application ... stoppre.sh

After snapshot I use this script for post:
https://github.com/VeeamHub/application ... toppost.sh

When I run wit Veeam I got the following error in log:

Code: Select all

[21.10.2022 15:56:07] <31> Info         [ScriptInvoker] Linux script exit code = '1'
[21.10.2022 15:56:07] <31> Error        [ScriptInvoker] Exception caught while executing script
I copy the script directly on Linus server and when I run it, I got the following error:

Code: Select all

./pre-freeze_cold.sh: line 15: /etc/init.d/mysqld: No such file or directory
I checked and really there isn't mysqld file. Why? Can I modify the script where locate the mysqld?

Thanks.
Mildur
Product Manager
Posts: 8678
Liked: 2275 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Pre-freeze/post-thaw not working on Zabbix server

Post by Mildur » 1 person likes this post

Hi Adam

Scripting is a try and error process.
Setup yourself a non production server, install mysql and try out this scripts. Modify them as you want until they work.

We can‘t tell you how the script must be build for your exact environment.
My suggestion:
Get familiar with this zabbix server. Get familiar what the script does. Find out where the mysql daemon binaries are stored. Adjust the script to use the new location.
Then run the script and analyze each error you get.
Also check out with your database admin or zabbix application owner if the script has worked.

Or get Zabbix support involved. They surely have a recommendation on how they want you to backup their application. Probably the already have working scripts you can use.

Thanks
Fabian
Product Management Analyst @ Veeam Software
adam900331
Veteran
Posts: 300
Liked: 22 times
Joined: Dec 01, 2019 7:27 pm
Contact:

Re: Pre-freeze/post-thaw not working on Zabbix server

Post by adam900331 » 1 person likes this post

Hy Fabian!

Thanks Your suggestion, its completely true that the pre/post script what include the VeeamHUB github site I have to modify to our environment. I thought these scripts are "universal" and its suitable to use all Linux server which contain mysql service. Now its clear, that it is not true. I tried out these pre/post scripts and modify some things, like mysql service location, now Veeam can run successfully the scripts:

Pre-Freeze (cold):

Code: Select all

#!/bin/bash

timeout=300

if [ -f /var/run/mysqld/mysqld.pid ]
then
	mysql_pid=$(cat /var/run/mysqld/mysqld.pid) >/dev/null 2>&1
else
	echo "$0 : Mysql not started or bad mysql pid file location" | logger
	exit 1
fi

echo "$0 : Processing pre-freeze backup script" | logger

sudo service mysql stop & > /dev/null 2>&1

c=0
while [ true ]
do
	if [ $c -gt $timeout ]
	then
		echo "$0 : timed out, mysql shutdown failed" | logger
		exit 2
	fi
	# check if mysql is running
	if [ -f /var/run/mysqld/mysqld.pid ]
	then
		echo "$0 : Waiting 5 more seconds for mysql shutdown" | logger
		sleep 5
		c=$((c+5))
	else
		echo "$0 : Mysql stopped" | logger
		sync;sync	
		break
	fi
done
Post-thaw (cold):

Code: Select all

#!/bin/bash

timeout=300

echo "$0 : processing post-thaw backup script" | logger

if [ -f /var/run/mysqld/mysqld.pid ]
then
	mysql_pid=$(cat /var/run/mysqld/mysqld.pid) >/dev/null 2>&1
	echo "$0 : Mysql already started with PID $mysql_pid" | logger
	exit 1
fi

sudo service mysql start & > /dev/null 2>&1

c=0
while [ true ]
do
	if [ $c -gt $timeout ]
	then
		echo "$0 : timed out, mysql startup failed" | logger
		exit 2
	fi
	# check if mysql is running
	if [ -f /var/run/mysqld/mysqld.pid ]
	then
		mysql_pid=$(cat /var/run/mysqld/mysqld.pid) >/dev/null 2>&1
		echo "$0 : MySQL started with pid $mysql_pid" | logger
		break
	else
		echo "$0 : Waiting 5 more seconds for mysql startup"
		sleep 5
		c=$((c+5))
	fi
done
Post Reply

Who is online

Users browsing this forum: juraj.zuziak and 89 guests