mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 18:06:35 +00:00
Fix backup failure at shutdown.
This fix include a new function of vzdump. Now you can call vzdump -stop and the backup will be aborted. Also if the pve-manager init script stop the process, vzdump -stop will called. Signed-off-by: Wolfgang Link <wolfgang@linksystems.org>
This commit is contained in:
parent
19ef60c5fa
commit
8682f6fcb1
@ -64,6 +64,10 @@ __PACKAGE__->register_method ({
|
|||||||
# silent exit if we run on wrong node
|
# silent exit if we run on wrong node
|
||||||
exit(0) if $param->{node} && $param->{node} ne $nodename;
|
exit(0) if $param->{node} && $param->{node} ne $nodename;
|
||||||
|
|
||||||
|
if($param->{stop}){
|
||||||
|
PVE::VZDump::stop_all_backups;
|
||||||
|
}
|
||||||
|
|
||||||
my $cmdline = PVE::VZDump::command_line($param);
|
my $cmdline = PVE::VZDump::command_line($param);
|
||||||
|
|
||||||
# convert string lists to arrays
|
# convert string lists to arrays
|
||||||
|
@ -22,6 +22,8 @@ my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
|
|||||||
|
|
||||||
my $lockfile = '/var/run/vzdump.lock';
|
my $lockfile = '/var/run/vzdump.lock';
|
||||||
|
|
||||||
|
my $pidfile = '/var/run/vzdump.pid';
|
||||||
|
|
||||||
my $logdir = '/var/log/vzdump';
|
my $logdir = '/var/log/vzdump';
|
||||||
|
|
||||||
my @plugins = qw (PVE::VZDump::OpenVZ);
|
my @plugins = qw (PVE::VZDump::OpenVZ);
|
||||||
@ -210,6 +212,8 @@ sub read_vzdump_defaults {
|
|||||||
$res->{lockwait} = int($1);
|
$res->{lockwait} = int($1);
|
||||||
} elsif ($line =~ m/stopwait:\s*(\d+)\s*$/) {
|
} elsif ($line =~ m/stopwait:\s*(\d+)\s*$/) {
|
||||||
$res->{stopwait} = int($1);
|
$res->{stopwait} = int($1);
|
||||||
|
} elsif ($line =~ m/stop:\s*(\d+)\s*$/) {
|
||||||
|
$res->{stop} = int($1);
|
||||||
} elsif ($line =~ m/size:\s*(\d+)\s*$/) {
|
} elsif ($line =~ m/size:\s*(\d+)\s*$/) {
|
||||||
$res->{size} = int($1);
|
$res->{size} = int($1);
|
||||||
} elsif ($line =~ m/maxfiles:\s*(\d+)\s*$/) {
|
} elsif ($line =~ m/maxfiles:\s*(\d+)\s*$/) {
|
||||||
@ -596,6 +600,15 @@ sub get_lvm_device {
|
|||||||
sub getlock {
|
sub getlock {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
|
my $fh;
|
||||||
|
|
||||||
|
open($fh, "> $pidfile")
|
||||||
|
or die "cannot open $pidfile: $!";
|
||||||
|
|
||||||
|
print $fh $$, "\n",PVE::ProcFSTools::read_proc_starttime($$), "\n";
|
||||||
|
|
||||||
|
close $fh || warn "close $pidfile failed: $!";
|
||||||
|
|
||||||
my $maxwait = $self->{opts}->{lockwait} || $self->{lockwait};
|
my $maxwait = $self->{opts}->{lockwait} || $self->{lockwait};
|
||||||
|
|
||||||
if (!open (SERVER_FLCK, ">>$lockfile")) {
|
if (!open (SERVER_FLCK, ">>$lockfile")) {
|
||||||
@ -1013,6 +1026,11 @@ sub exec_backup {
|
|||||||
|
|
||||||
my $opts = $self->{opts};
|
my $opts = $self->{opts};
|
||||||
|
|
||||||
|
if ($opts->{stop}) {
|
||||||
|
stop_all_backups($self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1);
|
debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1);
|
||||||
debugmsg ('info', "skip external VMs: " . join(', ', @{$self->{skiplist}}))
|
debugmsg ('info', "skip external VMs: " . join(', ', @{$self->{skiplist}}))
|
||||||
if scalar(@{$self->{skiplist}});
|
if scalar(@{$self->{skiplist}});
|
||||||
@ -1078,6 +1096,8 @@ sub exec_backup {
|
|||||||
die $err if $err;
|
die $err if $err;
|
||||||
|
|
||||||
die "job errors\n" if $errcount;
|
die "job errors\n" if $errcount;
|
||||||
|
|
||||||
|
unlink $pidfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $confdesc = {
|
my $confdesc = {
|
||||||
@ -1163,6 +1183,12 @@ my $confdesc = {
|
|||||||
description => "Store resulting file to this storage.",
|
description => "Store resulting file to this storage.",
|
||||||
optional => 1,
|
optional => 1,
|
||||||
}),
|
}),
|
||||||
|
stop => {
|
||||||
|
type => 'boolean',
|
||||||
|
description => "Stop all current runnig backup jobs on this host.",
|
||||||
|
optional => 1,
|
||||||
|
default => 0,
|
||||||
|
},
|
||||||
size => {
|
size => {
|
||||||
type => 'integer',
|
type => 'integer',
|
||||||
description => "LVM snapshot size in MB.",
|
description => "LVM snapshot size in MB.",
|
||||||
@ -1228,7 +1254,7 @@ sub verify_vzdump_parameters {
|
|||||||
my ($param, $check_missing) = @_;
|
my ($param, $check_missing) = @_;
|
||||||
|
|
||||||
raise_param_exc({ all => "option conflicts with option 'vmid'"})
|
raise_param_exc({ all => "option conflicts with option 'vmid'"})
|
||||||
if $param->{all} && $param->{vmid};
|
if ($param->{all} || $param->{stop}) && $param->{vmid};
|
||||||
|
|
||||||
raise_param_exc({ exclude => "option conflicts with option 'vmid'"})
|
raise_param_exc({ exclude => "option conflicts with option 'vmid'"})
|
||||||
if $param->{exclude} && $param->{vmid};
|
if $param->{exclude} && $param->{vmid};
|
||||||
@ -1238,10 +1264,35 @@ sub verify_vzdump_parameters {
|
|||||||
return if !$check_missing;
|
return if !$check_missing;
|
||||||
|
|
||||||
raise_param_exc({ vmid => "property is missing"})
|
raise_param_exc({ vmid => "property is missing"})
|
||||||
if !$param->{all} && !$param->{vmid};
|
if !($param->{all} || $param->{stop}) && !$param->{vmid};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub stop_all_backups {
|
||||||
|
my($self) = @_;
|
||||||
|
|
||||||
|
return if ! -e $pidfile;
|
||||||
|
|
||||||
|
my @param = split(/\n/,PVE::Tools::file_get_contents($pidfile));
|
||||||
|
my $pid;
|
||||||
|
my $stime;
|
||||||
|
|
||||||
|
if ($param[0] =~ /^([-\@\w.]+)$/){
|
||||||
|
$pid = $1;
|
||||||
|
}
|
||||||
|
if ($param[1] =~/^([-\@\w.]+)$/){
|
||||||
|
$stime = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(PVE::ProcFSTools::check_process_running($pid, $stime) &&
|
||||||
|
PVE::ProcFSTools::read_proc_starttime($pid) == $stime){
|
||||||
|
print "toll";
|
||||||
|
kill(15,$pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink $pidfile;
|
||||||
|
}
|
||||||
|
|
||||||
sub command_line {
|
sub command_line {
|
||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ case "$1" in
|
|||||||
pvesh --nooutput create /nodes/localhost/startall
|
pvesh --nooutput create /nodes/localhost/startall
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
echo "Stopping all running Backups"
|
||||||
|
vzdump -stop
|
||||||
echo "Stopping VMs and Containers"
|
echo "Stopping VMs and Containers"
|
||||||
pvesh --nooutput create /nodes/localhost/stopall
|
pvesh --nooutput create /nodes/localhost/stopall
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user