public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 3/3] vzdump: adapt to new keep-all prune option
Date: Mon, 23 Nov 2020 13:33:10 +0100	[thread overview]
Message-ID: <20201123123310.13898-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20201123123310.13898-1-f.ebner@proxmox.com>

Signed-off-by: Fabian Ebner <f.ebner@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





  parent reply	other threads:[~2020-11-23 12:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 12:33 [pve-devel] [PATCH storage 1/3] prune: introduce keep-all option Fabian Ebner
2020-11-23 12:33 ` [pve-devel] [PATCH storage 2/3] convert maxfiles to prune_backups when reading the storage configuration Fabian Ebner
2020-11-23 14:58   ` [pve-devel] applied: " Thomas Lamprecht
2020-11-23 12:33 ` Fabian Ebner [this message]
2020-11-23 14:58 ` [pve-devel] applied: [PATCH storage 1/3] prune: introduce keep-all option Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201123123310.13898-3-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal