]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: always pass full list to prune marking
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 6 Apr 2022 12:05:53 +0000 (14:05 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 6 Apr 2022 12:07:21 +0000 (14:07 +0200)
else this single call site is subtly different from all the rest, which
could cause problems further down the line if we ever change the prune
logic.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/VZDump.pm

index fe8a9b289aa8bab9c9b99e6ed19633b8c71c4fda..f34a5969b630c0ea03bd32a7aef2458ed16ac19e 100644 (file)
@@ -691,7 +691,7 @@ sub compressor_info {
     }
 }
 
-sub get_unprotected_backup_file_list {
+sub get_backup_file_list {
     my ($dir, $bkname) = @_;
 
     my $bklist = [];
@@ -699,11 +699,12 @@ sub get_unprotected_backup_file_list {
        my $archive_info = eval { PVE::Storage::archive_info($fn) } // {};
        if ($archive_info->{is_std_name}) {
            my $path = "$dir/$archive_info->{filename}";
-           next if -e PVE::Storage::protection_file_path($path);
            my $backup = {
                'path' => $path,
                'ctime' => $archive_info->{ctime},
            };
+           $backup->{mark} = "protected"
+               if -e PVE::Storage::protection_file_path($path);
            push @{$bklist}, $backup;
        }
     }
@@ -787,7 +788,7 @@ sub exec_backup_task {
                    !$_->{protected} && (!$_->{subtype} || $_->{subtype} eq $vmtype)
                } $backups->@*;
            } else {
-               $count = scalar(get_unprotected_backup_file_list($opts->{dumpdir}, $bkname)->@*);
+               $count = grep { !$_->{mark} || $_->{mark} ne "protected" } get_backup_file_list($opts->{dumpdir}, $bkname)->@*;
            }
 
            die "There is a max backup limit of $backup_limit enforced by the".
@@ -999,7 +1000,7 @@ sub exec_backup_task {
            debugmsg ('info', "prune older backups with retention: $keepstr", $logfd);
            my $pruned = 0;
            if (!defined($opts->{storage})) {
-               my $bklist = get_unprotected_backup_file_list($opts->{dumpdir}, $bkname);
+               my $bklist = get_backup_file_list($opts->{dumpdir}, $bkname);
 
                PVE::Storage::prune_mark_backup_group($bklist, $prune_options);