Preparing for Application Consistent backups
TrilioVault for RHV does provide the capabilties to take application consistent backups by utilizing the Qemu-Guest-Agent.

The Qemu-Guest-Agent

The Qemu-Guest-Agent is a component of the qemu hypervisor, which is used by RHV. RHV automatically builds all VMs to be prepared to use the Qemu-Guest-Agent.
The Qemu-Guest-Agent provides many capabilities, including the possibility to freeze and thaw Virtual Machines Filesystems.
The Qemu-Guest-Agent is not developed or maintained by Trilio. Trilio does leverage standard capabilities of the Qemu-Guest-Agent to send freeze and thaw commands to the protected VMS during a backup process.

Installing the Qemu-Guest-Agent

The Qemu-Guest-Agent needs to be installed inside the VM.
The Qemu-Guest-Agent requires a special SCSI interface in the VM definition. This interface is automatically created by RHV upon spinning up the Virtual Machine.
The installation process depends on the Guest Operating System.

RPM-based Guests

1
yum install qemu-guest-agent
2
systemctl start qemu-guest-agent
Copied!

Deb-based Guests

1
apt-get install qemu-guest-agent
2
systenctk start qemu-guest-agent
Copied!

Windows Guests

Windows Guests require the installation of the VirtIO drivers and tools. These are provided by Red Hat in a prepared ISO-file. For RHV 4.3 please follow this documentation: RHV 4.3 Windows Guest Agents For RHV 4.4 please follow this documentation: RHV 4.4 Windows Guest Agents

Using the fsfreeze-hook.sh script

The Qemu-Guest-Agent is calling the fsfreeze-hook.sh script either with the freeze or the thaw argument depending on the current operation.
The fsfreeze-hook.sh script is a normal shell script. It is typically used to do all necessary steps to get an application into a consistent state for the freeze or to undo all freeze operations upon the thaw.

Location of the fsfreeze-hook.sh script

The fs-freeze-hook.sh script default path is:
1
/etc/qemu/fsfreeze-hook
Copied!

Content of the fsfreeze-hook.sh script

The fsfreeze-hook.sh script does not require a special content.
It is recommended to provide a case identifier for the freeze and thaw argument. This can be achieved for example by the following bash code:
1
#!/bin/bash
2
3
case "$1" in
4
freeze)
5
#Commands for freeze
6
;;
7
8
thaw)
9
#Commands for thaw
10
;;
11
12
*)
13
echo quot;Neither freeze nor thaw provided"
14
exit 1
15
;;
16
17
esac
Copied!

Example fsfreeze-hook.sh for MYSQL

This example flushes the MySQL tables to the disks and keeps a read lock to prevent further write access until the thaw has been done.
1
#!/bin/sh
2
3
MYSQL="/usr/bin/mysql"
4
MYSQL_OPTS="-uroot" #"-prootpassword"
5
FIFO=/var/run/mysql-flush.fifo
6
# Check mysql is installed and the server running
7
[ -x "$MYSQL" ] && "$MYSQL" $MYSQL_OPTS < /dev/null || exit 0
8
flush_and_wait() {
9
printf "FLUSH TABLES WITH READ LOCK \\G\n"
10
trap 'printf "$(date): $0 is killed\n">&2' HUP INT QUIT ALRM TERM
11
read < $FIFO
12
printf "UNLOCK TABLES \\G\n"
13
rm -f $FIFO
14
}
15
case "$1" in
16
freeze)
17
mkfifo $FIFO || exit 1
18
flush_and_wait | "$MYSQL" $MYSQL_OPTS &
19
# wait until every block is flushed
20
while [ "$(echo 'SHOW STATUS LIKE "Key_blocks_not_flushed"' |\
21
"$MYSQL" $MYSQL_OPTS | tail -1 | cut -f 2)" -gt 0 ]; do
22
sleep 1
23
done
24
# for InnoDB, wait until every log is flushed
25
INNODB_STATUS=$(mktemp /tmp/mysql-flush.XXXXXX)
26
[ $? -ne 0 ] && exit 2
27
trap "rm -f $INNODB_STATUS; exit 1" HUP INT QUIT ALRM TERM
28
while :; do
29
printf "SHOW ENGINE INNODB STATUS \\G" |\
30
"$MYSQL" $MYSQL_OPTS > $INNODB_STATUS
31
LOG_CURRENT=$(grep 'Log sequence number' $INNODB_STATUS |\
32
tr -s ' ' | cut -d' ' -f4)
33
LOG_FLUSHED=$(grep 'Log flushed up to' $INNODB_STATUS |\
34
tr -s ' ' | cut -d' ' -f5)
35
[ "$LOG_CURRENT" = "$LOG_FLUSHED" ] && break
36
sleep 1
37
done
38
rm -f $INNODB_STATUS
39
;;
40
thaw)
41
[ ! -p $FIFO ] && exit 1
42
echo > $FIFO
43
;;
44
*)
45
echo quot;Neither freeze nor thaw provided"
46
exit 1
47
;;
48
esac
Copied!
Last modified 11mo ago