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 container 4/5] vzdump: allow relative exclude patterns for snapshot and stop mode
Date: Fri, 20 Nov 2020 15:50:44 +0100	[thread overview]
Message-ID: <20201120145045.31543-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20201120145045.31543-1-f.ebner@proxmox.com>

to make the behavior consistent across modes.

For suspend mode, relative patterns worked for a long time, because the
exclusion already happens when rsync copies the data during an earlier stage of
the backup.

For the other two methods, the way the patterns are passed to tar (after the
'--anchored' option and prefixed with a dot) meant that relative patterns
had no effect previously.

Users which have a relative exclude path by accident (if it's not by accident
then this fixes the behavior) and did not use suspend mode (if they did use
suspend mode, they hopefully would have noticed the unintended exclusion then)
will be affected by this change.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

The alternative way to make things consistent is to warn/die on relative
patterns and not pass along relative patterns to rsync. That would be a breaking
change for the (likely few) existing users of relative patterns.

With the approach from the patch, the behavior is also consisten with pxar/manual
usage of proxmox-backup-client. And the next patch further unifies the behavior for
non-manual usage of the backup client.

 src/PVE/VZDump/LXC.pm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index c02c6e1..eb07430 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -426,9 +426,23 @@ sub archive {
 	push @$tar, "--directory=$tmpdir", './etc/vzdump/pct.conf';
 	push @$tar, "./etc/vzdump/pct.fw" if $task->{fw};
 	push @$tar, "--directory=$snapdir";
-	push @$tar, '--no-anchored', '--exclude=lost+found' if $userns_cmd;
+
+	my @findexcl_no_anchored = ();
+	my @findexcl_anchored = ();
+	foreach my $pattern (@{$findexcl}) {
+	    if ($pattern !~ m|^/|) {
+		push @findexcl_no_anchored, $pattern;
+	    } else {
+		push @findexcl_anchored, $pattern;
+	    }
+	}
+
+	push @$tar, '--no-anchored';
+	push @$tar, '--exclude=lost+found' if $userns_cmd;
+	push @$tar, map { "--exclude=$_" } @findexcl_no_anchored;
+
 	push @$tar, '--anchored';
-	push @$tar, map { "--exclude=.$_" } @{$findexcl};
+	push @$tar, map { "--exclude=.$_" } @findexcl_anchored;
 
 	push @$tar, @sources;
 
-- 
2.20.1





  parent reply	other threads:[~2020-11-20 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 14:50 [pve-devel] [PATCH-SERIES] unify vzdump exclude-path behavior Fabian Ebner
2020-11-20 14:50 ` [pve-devel] [PATCH guest-common 1/5] vzdump: update exclude-path description Fabian Ebner
2020-11-20 14:50 ` [pve-devel] [PATCH docs 2/5] vdzump: extend examples to also cover relative patterns Fabian Ebner
2020-11-20 14:50 ` [pve-devel] [PATCH container 3/5] vzdump: turn findexcl into its own variable Fabian Ebner
2020-11-20 14:50 ` Fabian Ebner [this message]
2020-11-20 14:50 ` [pve-devel] [PATCH container 5/5] vzdump: pass along exclude patterns to proxmox-backup-client Fabian Ebner
2020-11-24 16:03 ` [pve-devel] applied-series: [PATCH-SERIES] unify vzdump exclude-path behavior Fabian Grünbichler

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=20201120145045.31543-5-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