View Full Version : hook script to backup the conf file separately

03-08-2011, 03:50 PM
Hi, i would like to have the *.conf files available out of the tgz file.
In the past i tried modifying vzdump itself, and works, but of course that work is thrown away at each vzdump update, and my "patch" hasn't been incorporated in the standard pve

I think i can do a similar thing using the "hook script" feature of vzdump (--script)

i thought to make the script, in the "log-end" phase, to copy the <vmid>.conf file into the same dir where the .log and .tgz files are saved, with the same .tgz filename but with ".conf" appended (so to preserve its relation with a specific backup session).

i want to backup also this file, along with tgz and log, in order to be sure of the vm NAME, apart the ID, that is in the file i am restoring from. That would make me happier :D

i thought to add this in the example hook script i found in /usr/share/doc/vzdump/examples/hook-script.pl:

if ($phase eq 'log-end') {
if ($vmtype eq 'qemu') {
system ("cp /etc/qemu-server/$hostname.conf $dumpdir/$tarfile.conf ") == 0 ||
die "copy conf file to dumpdir failed";
} elsif ($vmtype eq 'openvz') {
system ("cp /etc/vz/conf/$hostname.conf $dumpdir/$tarfile.conf ") == 0 ||
die "copy conf file to dumpdir failed";
would that work?
is there any similar example?
do anybody use other methods?

how would behave the next day vzdump session? would it delete this file?

Thanks, Marco

03-08-2011, 05:06 PM
do anybody use other methods?
Hi Marco,
i use rsync to save daily the whole content of /etc/qemu-server (i have kvm-only) to a backup directory on the other node. So i can quick start the VMs if one node lost (and the VM use shared storage).
Another benefit is that i have a backup from all vm-configs, because i don't use the pve-backup for all VMs.