Maybe a way to bypass the problem would be to run the vm only when needed to run the backup so it would not keep my
disks spinning since it will be shutdown.
I tried to use the vzdump-hook-script.pl to auto start vm 100 at the start of the backup and auto shutdown the vm
at the end of the backup .
(added at /etc/vzdump.conf:
script: /usr/local/bin/vzdump-hook-script.pl
)
I could not find the vzdump-hook-script.pl that was mentioned at the documentantion so I downloaded one version from git.
Here is my script:
#!/usr/bin/perl -w
# Example hook script for vzdump (--script option)
# This can also be added as a line in /etc/vzdump.conf
# e.g. 'script: /usr/local/bin/vzdump-hook-script.pl'
use strict;
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
if ($phase eq 'job-start' ||
$phase eq 'job-end' ||
$phase eq 'job-abort') {
my $dumpdir = $ENV{DUMPDIR};
my $storeid = $ENV{STOREID};
print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n";
# do what you want
# example: copy resulting log file to another host using scp
if ($phase eq 'job-start') {
system ("/usr/sbin/pct start 100| sleep 60")
#== 0 ||
# die "pbs start failed";
}
if ($phase eq 'job-end') {
system ("sleep 2200 && /usr/sbin/pct shutdown 100")
#== 0 ||
# die "pbs start failed";
}
if ($phase eq 'job-abort') {
system ("sleep 2200 && /usr/sbin/pct shutdown 100")
}
} elsif ($phase eq 'backup-start' ||
$phase eq 'backup-end' ||
$phase eq 'backup-abort' ||
$phase eq 'log-end' ||
$phase eq 'pre-stop' ||
$phase eq 'pre-restart' ||
$phase eq 'post-restart') {
my $mode = shift; # stop/suspend/snapshot
my $vmid = shift;
my $vmtype = $ENV{VMTYPE}; # lxc/qemu
my $dumpdir = $ENV{DUMPDIR};
my $storeid = $ENV{STOREID};
my $hostname = $ENV{HOSTNAME};
# target is only available in phase 'backup-end'
my $target = $ENV{TARGET};
# logfile is only available in phase 'log-end'
my $logfile = $ENV{LOGFILE};
print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;target=$target;logfile=$logfile\n";
} else {
die "got unknown phase '$phase'";
}
exit (0);
The above script works for me
Only receive :
Use of uninitialized value $dumpdir in concatenation (.) or string at /usr/local/bin/vzdump-hook-script.pl line 22.
Use of uninitialized value $logfile in concatenation (.) or string at /usr/local/bin/vzdump-hook-script.pl line 69.
but the script works
I think temporarily is a workable hack till we find a way to enable disk sleep
I have put a sleep 2200 secs at end of backup before shutdown to let it enough time to do garbage collection,pruning,verify ( I have
scheduled to do it every 30min and verify next time 1 month).I hope the server will not try to do all these at the same time and overloads