]> git.proxmox.com Git - pve-storage.git/commitdiff
prune: mark renamed and protected backups differently
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 30 Sep 2021 11:42:09 +0000 (13:42 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 8 Nov 2021 13:56:15 +0000 (14:56 +0100)
While it makes no difference for pruning itself, protected backups are
additionally protected against removal. Avoid the potential to confuse
the two. Also update the description for the API return value and add
an enum constraint.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/API2/Storage/PruneBackups.pm
PVE/Storage/Plugin.pm
test/prune_backups_test.pm

index 2509a46ec2e8122a2d6bd96ae88ab422f20ac973..e6ab2761529fccc82ee44f21d06ccbc1c06d4ebc 100644 (file)
@@ -61,9 +61,10 @@ __PACKAGE__->register_method ({
                    type => 'integer',
                },
                'mark' => {
-                   description => "Whether the backup would be kept or removed. For backups that don't " .
-                                  "use the standard naming scheme, it's 'protected'.",
+                   description => "Whether the backup would be kept or removed. Backups that are" .
+                       " protected or don't use the standard naming scheme are not removed.",
                    type => 'string',
+                   enum => ['keep', 'remove', 'protected', 'renamed'],
                },
                type => {
                    description => "One of 'qemu', 'lxc', 'openvz' or 'unknown'.",
index 409a05cbf8ef328d73135a69f00a2b21c198133a..7d2487fc1c68cca36b2b3e337f2bee501e8ae4c1 100644 (file)
@@ -1372,7 +1372,7 @@ sub prune_backups {
            push @{$backup_groups->{$group}}, $prune_entry;
        } else {
            # ignore backups that don't use the standard naming scheme
-           $prune_entry->{mark} = 'protected';
+           $prune_entry->{mark} = 'renamed';
        }
 
        $prune_entry->{mark} = 'protected' if $backup->{protected};
index 8ad61449cdfa02f23f907316d47daa6954a48ea4..b57d2801426101eaa12777540b7ff627b390fdbb 100644 (file)
@@ -189,7 +189,7 @@ sub generate_expected {
                'volid' => "$storeid:backup/vzdump-$vmid-renamed.tar.zst",
                'type'  => 'unknown',
                'ctime' => 1234,
-               'mark'  => 'protected',
+               'mark'  => 'renamed',
                'vmid'  => $vmid,
            },
        ) if !defined($type);
@@ -375,7 +375,7 @@ my $tests = [
            {
                'volid' => "$storeid:backup/vzdump-lxc-novmid.tar.gz",
                'ctime' => 1234,
-               'mark'  => 'protected',
+               'mark'  => 'renamed',
                'type'  => 'lxc',
            },
        ],