[pve-devel] [PATCH manager 3/3] vzdump: adapt to new keep-all prune option

Fabian Ebner f.ebner at proxmox.com
Mon Nov 23 13:33:10 CET 2020


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/VZDump.pm | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 59062d2b..178f37f5 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -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}) {
-- 
2.20.1






More information about the pve-devel mailing list