From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9A3801FF0B7 for ; Fri, 13 Nov 2026 10:06:11 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 18CF5217C9; Fri, 13 Nov 2026 10:06:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stuttgart.de; s=s1022; t=1794560286; bh=sJVMX7L216hNQv358QG52no+DCHrFSOWX+8SMikUFJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqmiQQsxsol9qsaVtazAcSzwA35/LzxH2WwbWRJCNJNlDUXHBi/CZevkvyQMc++jR DofhczX6ojIOfcqc5RWlOge8jUJ1Ey79wvWdpiBsCtTkT9QIjPg8QJ+j+z4/DZOyVq GeTdJn08fjmETCA1XEFuba9LIrjXxqi4VhVvDV3G1ZUiLhMYx3PlY3X2H4iCzli6Qw +vgrt/7BjvbqJchRfl11k3aGJlrO8/Oc09c744lz8gTzQ4rswcxnRYDGUD+b+vMmi5 sIRoQoAoPtzFA6EyxW65cMIrMCBELqdrtJJsikjd8/q+YhEZD/MEKSzPWhq1K4vGKC hOF3TO4L3DPEg== From: Jakob-Tobias Winter To: pbs-devel@lists.proxmox.com Subject: [RFC PATCH manager 10/12] vzdump: store guest tags and pool as snapshot attributes on PBS Date: Fri, 13 Nov 2026 09:56:37 +0100 Message-ID: <20261113085637.57360-13-tobias@stuttgart.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261113085637.57360-3-tobias@stuttgart.de> References: <20261113085637.57360-3-tobias@stuttgart.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: M32ZDQHDABXEEZKJPAOFJ2MY5HLJB42V X-Message-ID-Hash: M32ZDQHDABXEEZKJPAOFJ2MY5HLJB42V X-MailFrom: prvs=d19b210678=tobias@stuttgart.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob-Tobias Winter X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A Proxmox Backup Server only knows the type and the ID of a guest, so its jobs cannot select backups by what guests are organized with in Proxmox VE: tags and resource pools. After a backup to a Proxmox Backup Server, store the tags and the resource pool of the guest as attributes of the new snapshot. A tape backup job on the server can then, for example, write the guests tagged as production to another media pool than the test guests. The keys 'pve-tag' and 'pve-pool' are prefixed as suggested in [0], to tell them from attributes set by others. There is one 'pve-tag' value for each tag, tags are never joined into one value. A guest in a nested pool gets a 'pve-pool' value for that pool and for each of its parent pools. That way a filter for a pool on the server also matches the guests of the pools nested in it, without naming each of them. Like for the notes, a failure is only logged as warning. A server which does not support attributes yet only causes a note in the log, so backups to older servers are not affected. The attributes are also set for guests without tags and pool, so the server can tell them from guests which were backed up without this feature. This can be disabled with the pbs-snapshot-attributes option, as the attributes are stored unencrypted. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=4186#c32 Signed-off-by: Jakob-Tobias Winter --- Needs versioned dependency bumps for libpve-storage-perl (patch 8) and libpve-guest-common-perl (patch 9). Without the helper of patch 8 each backup to a PBS storage would log a warning, without the option of patch 9 no attributes are set. PVE/VZDump.pm | 42 ++++++++++++++++++++++++++++++++++++++++++ configs/vzdump.conf | 1 + 2 files changed, 43 insertions(+) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 56d2aea3..aa337dc9 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -16,6 +16,7 @@ use Time::Local; use PVE::Cluster qw(cfs_read_file); use PVE::DataCenterConfig; use PVE::Exception qw(raise_param_exc); +use PVE::GuestHelpers; use PVE::HA::Config; use PVE::HA::Env::PVE2; use PVE::JSONSchema qw(get_standard_option); @@ -144,6 +145,31 @@ my $generate_notes = sub { return $notes_template; }; +# Returns the tags and the resource pool of a guest as list of snapshot attributes for a Proxmox +# Backup Server. Each attribute is a 'KEY=VALUE' string, so there is one entry for each tag, and +# for a guest in a nested pool one entry for that pool and for each of its parent pools. +my $get_snapshot_attributes = sub { + my ($vmid) = @_; + + my $attributes = []; + + my $props = PVE::Cluster::get_guest_config_properties(['tags'], $vmid); + my $tags = PVE::GuestHelpers::get_unique_tags($props->{$vmid}->{tags}, 1); + for my $tag ($tags->@*) { + push $attributes->@*, "pve-tag=$tag" + if defined(PVE::JSONSchema::pve_verify_tag($tag, 1)); + } + + my $usercfg = cfs_read_file('user.cfg'); + my $pool = $usercfg->{vms}->{$vmid}; + while (defined($pool)) { + push $attributes->@*, "pve-pool=$pool"; + ($pool) = $pool =~ m!^(.+)/[^/]+$!; # continue with the parent of a nested pool + } + + return $attributes; +}; + sub parse_fleecing { my ($param) = @_; @@ -1237,6 +1263,22 @@ sub exec_backup_task { } } + if ($opts->{pbs} && $opts->{'pbs-snapshot-attributes'}) { + debugmsg('info', "adding tags and pool as snapshot attributes", $logfd); + eval { + my $attributes = $get_snapshot_attributes->($vmid); + my $supported = PVE::Storage::PBSPlugin->update_snapshot_attributes( + $opts->{scfg}, $storeid, "backup/$volname", $attributes, + ); + debugmsg( + 'info', + "snapshot attributes are not supported by the server", + $logfd, + ) if !$supported; + }; + debugmsg('warn', "unable to add snapshot attributes - $@", $logfd) if $@; + } + if ($opts->{protected}) { debugmsg('info', "marking backup as protected", $logfd); eval { PVE::Storage::update_volume_attribute($cfg, $volid, 'protected', 1) }; diff --git a/configs/vzdump.conf b/configs/vzdump.conf index 1835e208..7573878f 100644 --- a/configs/vzdump.conf +++ b/configs/vzdump.conf @@ -17,4 +17,5 @@ #pigz: N #notes-template: {{guestname}} #pbs-change-detection-mode: legacy|data|metadata +#pbs-snapshot-attributes: BOOLEAN #fleecing: enabled=BOOLEAN,storage=STORAGE_ID base-commit: 59c704fe844ad8027a46551ae58a3082f837db15 -- 2.53.0