[SOLVED] fsfreeze-hook is not getting triggered at the time of backup

Jayesh

Member
Sep 4, 2020
11
0
6
36
Hi,

pveversion:
pve-manager/6.2-12/b287dd27 (running kernel: 5.4.65-1-pve)

I have installed qemu-guest-agent install VM and KVM configuration contains agent: 1.
qm agent 124 ping return empty output mean guest agent is responding.

But recieving below output from freeze and thaw commands

root@serv1:~# qm agent 124 fsfreeze-freeze
8
root@serv1:~# qm agent 124 fsfreeze-thaw
8

And looks like fsfreeze-hook is not getting triggered. LOGFILE /var/log/qga-fsfreeze-hook.log is not getting created. Please check backup logs here..

INFO: starting new backup job: vzdump 124 --node serv1 --remove 0 --storage xxxx --compress zstd --mode snapshot
INFO: Starting Backup of VM 124 (qemu)
INFO: Backup started at 2021-01-19 12:38:56
INFO: status = running
INFO: VM Name: uat-db2
INFO: include disk 'scsi0' 'xxxxx-HDD:vm-124-disk-0' 140G
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: creating vzdump archive '/mnt/pve/xxxx/dump/vzdump-qemu-124-2021_01_19-12_38_56.vma.zst'
INFO: issuing guest-agent 'fs-freeze' command
INFO: issuing guest-agent 'fs-thaw' command
INFO: started backup task '3d0aef8c-8f84-4ea9-a8e4-7b80f7b173a7'
INFO: resuming VM again
INFO: 6% (8.6 GiB of 140.0 GiB) in 3s, read: 2.9 GiB/s, write: 61.7 MiB/s
INFO: 7% (10.5 GiB of 140.0 GiB) in 12s, read: 219.1 MiB/s, write: 125.0 MiB/s
INFO: 16% (22.5 GiB of 140.0 GiB) in 15s, read: 4.0 GiB/s, write: 49.1 MiB/s
INFO: 20% (29.1 GiB of 140.0 GiB) in 18s, read: 2.2 GiB/s, write: 95.4 MiB/s
INFO: 26% (36.7 GiB of 140.0 GiB) in 21s, read: 2.5 GiB/s, write: 67.3 MiB/s
INFO: 38% (54.4 GiB of 140.0 GiB) in 24s, read: 5.9 GiB/s, write: 301.3 KiB/s
INFO: 45% (63.7 GiB of 140.0 GiB) in 27s, read: 3.1 GiB/s, write: 86.9 MiB/s
INFO: 57% (80.9 GiB of 140.0 GiB) in 30s, read: 5.7 GiB/s, write: 52.0 KiB/s
INFO: 66% (93.7 GiB of 140.0 GiB) in 33s, read: 4.3 GiB/s, write: 34.1 MiB/s
INFO: 75% (106.1 GiB of 140.0 GiB) in 36s, read: 4.1 GiB/s, write: 22.9 MiB/s
INFO: 87% (122.1 GiB of 140.0 GiB) in 39s, read: 5.3 GiB/s, write: 5.3 MiB/s
INFO: 96% (135.3 GiB of 140.0 GiB) in 42s, read: 4.4 GiB/s, write: 901.3 KiB/s
INFO: 100% (140.0 GiB of 140.0 GiB) in 44s, read: 2.3 GiB/s, write: 0 B/s
INFO: backup is sparse: 137.66 GiB (98%) total zero data
INFO: transferred 140.00 GiB in 44 seconds (3.2 GiB/s)
INFO: archive file size: 626MB
INFO: Finished Backup of VM 124 (00:00:46)
INFO: Backup finished at 2021-01-19 12:39:42
INFO: Backup job finished successfully
TASK OK

What i am missing ? any ideas ?
 
Last edited:
Hi,
Hi,



I have installed qemu-guest-agent install VM and KVM configuration contains agent: 1.
qm agent 124 ping return empty output mean guest agent is responding.

But recieving below output from freeze and thaw commands
This is fine, it returns the number of frozen/thawed filesystems.

And looks like fsfreeze-hook is not getting triggered. LOGFILE /var/log/qga-fsfreeze-hook.log is not getting created. Please check backup logs here..



What i am missing ? any ideas ?
AFAICT there are no such hooks. You can find the existing backup hooks in the example script: /usr/share/doc/pve-manager/examples/vzdump-hook-script.pl.

EDIT: Sorry, I now realized you are talking about the guest-agent specific hook. How did you configure the guest agent in the VM?
 
Last edited:
Hi,

This is fine, it returns the number of frozen/thawed filesystems.


AFAICT there are no such hooks. You can find the existing backup hooks in the example script: /usr/share/doc/pve-manager/examples/vzdump-hook-script.pl.

EDIT: Sorry, I now realized you are talking about the guest-agent specific hook. How did you configure the guest agent in the VM?
Hi,

First of all Thanks for your immediate response..

I am using debian buster OS inside VM. Followed below method to configure the guest in the VM.

Code:
1) apt install qemu-guest-agent in VM
2) stopped VM
3) Enabled "Qemu Guest Agent" under Option menu of Proxmox GUI.
4) Started VM

qemu agent is running under default settings inside VM as there is no configuration file found inside /etc/qemu.


Thanks,
Jayesh
 
The default script that gets executed is /etc/qemu/fsfreeze-hook and by default it does not create any log file (because it has nothing to write to it).

You can place scripts in the directory /etc/qemu/fsfreeze-hook.d which the default script will iterate over and execute. It's important to make the scripts executable! Otherwise they will be silently skipped.

See also man qemu-ga if you don't want to use the default script.
 
The default script that gets executed is /etc/qemu/fsfreeze-hook and by default it does not create any log file (because it has nothing to write to it).

You can place scripts in the directory /etc/qemu/fsfreeze-hook.d which the default script will iterate over and execute. It's important to make the scripts executable! Otherwise they will be silently skipped.

See also man qemu-ga if you don't want to use the default script.
Hi,

I have already placed script inside said directory..
reference - https://github.com/qemu/qemu/blob/m...t-agent/fsfreeze-hook.d/mysql-flush.sh.sample


Code:
jayesh@uat-db2:~$ ls -l /etc/qemu/fsfreeze-hook.d/mysql-flush.sh
-rwxr-xr-x 1 root root 1769 Jan 19 10:53 /etc/qemu/fsfreeze-hook.d/mysql-flush.sh

But for some reason it is not executing. I am expecting some logs in /var/log/qga-fsfreeze-hook.log file. But that LOGFILE itself not getting created.

Code from fsfreeze-hook which should populate some logs:

Code:
printf "$(date): execute $file $@\n" >>$LOGFILE
    "$file" "$@" >>$LOGFILE 2>&1
    STATUS=$?
    printf "$(date): $file finished with status=$STATUS\n" >>$LOGFILE

To test if /etc/qemu/fsfreeze-hook is really getting triggered by fs.freeze and fs.thaw actions, I have added one command to create an empty file (/tmp/test1.txt).

Code:
#!/bin/sh


# This script is executed when a guest agent receives fsfreeze-freeze and
# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook).
# When the agent receives fsfreeze-freeze request, this script is issued with
# "freeze" argument before the filesystem is frozen. And for fsfreeze-thaw
# request, it is issued with "thaw" argument after filesystem is thawed.


LOGFILE=/var/log/qga-fsfreeze-hook.log
FSFREEZE_D=$(dirname -- "$0")/fsfreeze-hook.d


#Code added to create /tmp/test1.txt file whenever this script gets executed
touch /tmp/test1.txt


# Check whether file $1 is a backup or rpm-generated file and should be ignored
is_ignored_file() {
    case "$1" in
        *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave | *.sample | *.dpkg-old | *.dpkg-new | *.dpkg-tmp | *.dpkg-dist | *.dpkg-bak | *.dpkg-backup | *.dpkg-remove)
            return 0 ;;
    esac
    return 1
}


# Iterate executables in directory "fsfreeze-hook.d" with the specified args
[ ! -d "$FSFREEZE_D" ] && exit 0
for file in "$FSFREEZE_D"/* ; do
    is_ignored_file "$file" && continue
    [ -x "$file" ] || continue
    printf "$(date): execute $file $@\n" >>$LOGFILE
    "$file" "$@" >>$LOGFILE 2>&1
    STATUS=$?
    printf "$(date): $file finished with status=$STATUS\n" >>$LOGFILE
done


exit 0

But again /tmp/test1.txt is not getting created whenever backup job runs.
 
Please try running qemu-ga -D > /etc/qemu/qemu-ga.conf to dump the current configuration and adding a line
Code:
fsfreeze-hook= /etc/qemu/fsfreeze-hook
to that file. Then restart the service with systemctl restart qemu-guest-agent.service and test if it works by issuing freeze+thaw on the host.
 
Please try running qemu-ga -D > /etc/qemu/qemu-ga.conf to dump the current configuration and adding a line
Code:
fsfreeze-hook= /etc/qemu/fsfreeze-hook
to that file. Then restart the service with systemctl restart qemu-guest-agent.service and test if it works by issuing freeze+thaw on the host.
Perfect!! Its working now..

many thanks!!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!