]> git.proxmox.com Git - pmg-api.git/commitdiff
api: pbs backup: only say we prune if actually setup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Nov 2020 13:44:02 +0000 (14:44 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Nov 2020 13:44:02 +0000 (14:44 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/API2/PBS/Job.pm
src/PMG/PBSConfig.pm

index 336c73a59486d70fbe8cf9aca74f1970c6281ee4..9b289387a7213434c07566900de9fd664e886e5c 100644 (file)
@@ -272,18 +272,18 @@ __PACKAGE__->register_method ({
            print "backup finished\n";
 
            my $group = "host/$node";
-           print "starting prune of $group\n";
-           my $prune_opts = $conf->prune_options($remote);
-           my $res = $pbs->prune_group(undef, $prune_opts, $group);
-
-           foreach my $pruned (@$res){
-               my $time = strftime("%FT%TZ", gmtime($pruned->{'backup-time'}));
-               my $snap = $pruned->{'backup-type'} . '/' . $pruned->{'backup-id'} . '/' .  $time;
-               print "pruned snapshot: $snap\n";
+           if (defined(my $prune_opts = $conf->prune_options($remote))) {
+               print "starting prune of $group\n";
+               my $res = $pbs->prune_group(undef, $prune_opts, $group);
+
+               foreach my $pruned (@$res){
+                   my $time = strftime("%FT%TZ", gmtime($pruned->{'backup-time'}));
+                   my $snap = $pruned->{'backup-type'} . '/' . $pruned->{'backup-id'} . '/' .  $time;
+                   print "pruned snapshot: $snap\n";
+               }
+               print "prune finished\n";
            }
 
-           print "prune finished\n";
-
            return;
        };
 
index 122ae992b3815dc527fca0898d323758b78a549d..2d80e78230d050df54c5954ad328daf986b0c499 100644 (file)
@@ -125,12 +125,14 @@ sub prune_options {
     my $remote_cfg = $self->{ids}->{$remote};
 
     my $res = {};
+    my $pruning_setup;
     foreach my $keep_opt (keys %prune_properties) {
        if (defined($remote_cfg->{$keep_opt})) {
+           $pruning_setup = 1;
            $res->{$keep_opt} = $remote_cfg->{$keep_opt};
        }
     }
-    return $res;
+    return $pruning_setup ? $res : undef;
 }
 
 sub new {