hook script to backup the conf file separately

m.ardito

Active Member
Feb 17, 2010
1,473
16
38
Torino, Italy
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:


Code:
    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
 
...
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.

Udo
 

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!