]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: adapt to new keep-all prune option
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 23 Nov 2020 12:33:10 +0000 (13:33 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 23 Nov 2020 15:03:08 +0000 (16:03 +0100)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/VZDump.pm

index 59062d2be711e66d24e092b567b36ce5628a53c0..178f37f5fd53e8a2d2cfe85abe8adfdd8a38d655 100644 (file)
@@ -494,11 +494,13 @@ sub new {
        if ($maxfiles) {
            $opts->{'prune-backups'} = { 'keep-last' => $maxfiles };
        } else {
-           # maxfiles being zero means keep all, so avoid triggering any remove code path to be safe
-           $opts->{remove} = 0;
+           $opts->{'prune-backups'} = { 'keep-all' => 1 };
        }
     }
 
+    # avoid triggering any remove code path if keep-all is set
+    $opts->{remove} = 0 if $opts->{'prune-backups'}->{'keep-all'};
+
     if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {
        $errors .= "\n" if $errors;
        $errors .= "tmpdir '$opts->{tmpdir}' does not exist";
@@ -735,8 +737,13 @@ sub exec_backup_task {
        my $prune_options = $opts->{'prune-backups'};
 
        my $backup_limit = 0;
-       foreach my $keep (values %{$prune_options}) {
-           $backup_limit += $keep;
+       my $keep_all = delete $prune_options->{'keep-all'};
+       if ($keep_all) {
+           $prune_options = { 'keep-all' => 1 };
+       } else {
+           foreach my $keep (values %{$prune_options}) {
+               $backup_limit += $keep;
+           }
        }
 
        if ($backup_limit && !$opts->{remove}) {