mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-06-05 04:01:20 +00:00
vzdump: set task mode early to fix a warning
when a vzdump script is set and the backup fails early (eg. when exceeding the number of backups) run_hook_script() showed an uninitialized value error trying to use $task->{mode} which is set only after prepare() was called. This sets $task->{mode} early, still updated later to $stop if !$running, and changes the condition for whether cleanup() should be called to not use $task->{mode} (which makes no real sense anyway) to using the $cleanup hash like the rest of the code.
This commit is contained in:
parent
de7eeaac1c
commit
6acb632a54
@ -861,7 +861,7 @@ sub exec_backup_task {
|
||||
|
||||
# prepare
|
||||
|
||||
my $mode = $running ? $opts->{mode} : 'stop';
|
||||
my $mode = $running ? $task->{mode} : 'stop';
|
||||
|
||||
if ($mode eq 'snapshot') {
|
||||
my %saved_task = %$task;
|
||||
@ -875,6 +875,8 @@ sub exec_backup_task {
|
||||
}
|
||||
}
|
||||
|
||||
$cleanup->{prepared} = 1;
|
||||
|
||||
$task->{mode} = $mode;
|
||||
|
||||
debugmsg ('info', "backup mode: $mode", $logfd);
|
||||
@ -1013,7 +1015,7 @@ sub exec_backup_task {
|
||||
warn $@ if $@;
|
||||
}
|
||||
|
||||
if (defined($task->{mode})) {
|
||||
if ($cleanup->{prepared}) {
|
||||
# only call cleanup when necessary (when prepare was executed)
|
||||
eval { $plugin->cleanup ($task, $vmid) };
|
||||
warn $@ if $@;
|
||||
@ -1096,7 +1098,7 @@ sub exec_backup {
|
||||
foreach my $vmid (sort @$vmlist) {
|
||||
next if grep { $_ eq $vmid } @{$opts->{exclude}};
|
||||
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Backup' ], 1);
|
||||
push @$tasklist, { vmid => $vmid, state => 'todo', plugin => $plugin };
|
||||
push @$tasklist, { vmid => $vmid, state => 'todo', plugin => $plugin, mode => $opts->{mode} };
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1110,7 +1112,7 @@ sub exec_backup {
|
||||
}
|
||||
}
|
||||
$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Backup' ]);
|
||||
push @$tasklist, { vmid => $vmid, state => 'todo', plugin => $plugin };
|
||||
push @$tasklist, { vmid => $vmid, state => 'todo', plugin => $plugin, mode => $opts->{mode} };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user