The vzdump hook became specific to Debian Jessie

It will link the last tar file to a better name.
This commit is contained in:
Jeremy Gardais 2018-02-13 11:37:33 +01:00
parent cc5edc015c
commit 2add0a1412
1 changed files with 14 additions and 3 deletions

View File

@ -4,6 +4,8 @@
# Template directory
my $TEMPLATE_DIR = "/mnt/zfsbkp/template/cache";
# Template file name
my $TEMPLATE_FILE_LINK = "jessie.template.ipr.univ-rennes1.fr.tar.gz"
# Number of template to keep available
my $RETENTION_TIME = "2";
@ -55,12 +57,21 @@ if ($phase eq 'job-start' ||
# copy resulting backup file as a template
if ($phase eq 'backup-end') {
# Ensure to remove template older than $RETENTION_TIME
system ("find $TEMPLATE_DIR -iname 'vzdump-lxc-$vmid*.tar.*' -mtime +$RETENTION_TIME -delete ") == 0 ||
die "remove oldest template failed";
# Copy the dump as a LXC template
system ("cp -- $tarfile $TEMPLATE_DIR") == 0 ||
die "copy tar file as a template failed";
# Unlink (eg hostname=jessietpl.ipr.univ-rennes1.fr)
system ("unlink $TEMPLATE_DIR/$TEMPLATE_FILE_LINK")
# no die cause if the previous backup exit on tarfile copy, the link might not exist
# Link last template file to a better name
system ("find $TEMPLATE_DIR -iname 'vzdump-lxc-$vmid*.tar.*' -mmin -60 -exec ln -s {} $TEMPLATE_DIR/$TEMPLATE_FILE_LINK \;") == 0 ||
die "link template to a better name failed";
# Ensure to remove template older than $RETENTION_TIME
system ("find $TEMPLATE_DIR -iname 'vzdump-lxc-$vmid*.tar.*' -mtime +$RETENTION_TIME -delete ") == 0 ||
die "remove oldest template failed";
}
} else {