The vzdump hook became specific to Debian Jessie
It will link the last tar file to a better name.
This commit is contained in:
parent
cc5edc015c
commit
2add0a1412
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
# Template directory
|
# Template directory
|
||||||
my $TEMPLATE_DIR = "/mnt/zfsbkp/template/cache";
|
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
|
# Number of template to keep available
|
||||||
my $RETENTION_TIME = "2";
|
my $RETENTION_TIME = "2";
|
||||||
|
|
||||||
|
@ -55,12 +57,21 @@ if ($phase eq 'job-start' ||
|
||||||
|
|
||||||
# copy resulting backup file as a template
|
# copy resulting backup file as a template
|
||||||
if ($phase eq 'backup-end') {
|
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
|
# Copy the dump as a LXC template
|
||||||
system ("cp -- $tarfile $TEMPLATE_DIR") == 0 ||
|
system ("cp -- $tarfile $TEMPLATE_DIR") == 0 ||
|
||||||
die "copy tar file as a template failed";
|
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 {
|
} else {
|
Loading…
Reference in New Issue