From: Jakob-Tobias Winter <tobias@stuttgart.de>
To: pbs-devel@lists.proxmox.com
Cc: Jakob-Tobias Winter <tobias@stuttgart.de>
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 [thread overview]
Message-ID: <20261113085637.57360-13-tobias@stuttgart.de> (raw)
In-Reply-To: <20261113085637.57360-3-tobias@stuttgart.de>
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 <tobias@stuttgart.de>
---
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
next prev parent reply other threads:[~2026-11-13 9:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 8:56 [RFC PATCH many 00/12] snapshot attributes for tags and pools of PVE guests, tape job filter Jakob-Tobias Winter
2026-11-13 8:56 ` [RFC PATCH proxmox 01/12] pbs-api-types: add types and schemas for snapshot attributes Jakob-Tobias Winter
2026-11-16 14:57 ` Christian Ebner
2026-11-18 12:54 ` Samuel Rufinatscha
2026-11-13 8:56 ` [RFC PATCH proxmox 02/12] pbs-api-types: tape: add attribute filter to backup jobs Jakob-Tobias Winter
2026-11-16 14:57 ` Christian Ebner
2026-11-13 8:56 ` [RFC PATCH proxmox-backup 03/12] datastore: add attributes to backup snapshots Jakob-Tobias Winter
2026-11-16 14:57 ` Christian Ebner
2026-11-18 12:55 ` Samuel Rufinatscha
2026-11-13 8:56 ` [RFC PATCH proxmox-backup 04/12] fix #7452: api: datastore: add endpoints for snapshot attributes Jakob-Tobias Winter
2026-11-16 14:57 ` Christian Ebner
2026-11-13 8:56 ` [RFC PATCH proxmox-backup 05/12] tape: backup job: allow selecting groups by " Jakob-Tobias Winter
2026-11-18 13:06 ` Samuel Rufinatscha
2026-11-18 15:19 ` Christian Ebner
2026-11-13 8:56 ` [RFC PATCH proxmox-backup 06/12] ui: tape backup job: add attribute filter Jakob-Tobias Winter
2026-11-13 8:56 ` [RFC PATCH proxmox-backup 07/12] docs: describe snapshot attributes and the tape job " Jakob-Tobias Winter
2026-11-13 8:56 ` [RFC PATCH storage 08/12] pbs: add helper to set the attributes of a backup snapshot Jakob-Tobias Winter
2026-11-13 8:56 ` [RFC PATCH guest-common 09/12] vzdump: add pbs-snapshot-attributes option Jakob-Tobias Winter
2026-11-13 8:56 ` Jakob-Tobias Winter [this message]
2026-11-13 8:56 ` [RFC PATCH manager 11/12] ui: backup job: add selector for PBS snapshot attributes Jakob-Tobias Winter
2026-11-13 8:56 ` [RFC PATCH docs 12/12] vzdump: describe snapshot attributes on Proxmox Backup Server Jakob-Tobias Winter
2026-11-16 14:57 ` [RFC PATCH many 00/12] snapshot attributes for tags and pools of PVE guests, tape job filter Christian Ebner
2026-11-18 13:07 ` Samuel Rufinatscha
2026-11-18 14:22 ` Samuel Rufinatscha
2026-11-19 11:58 ` Jakob-Tobias Winter
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=20261113085637.57360-13-tobias@stuttgart.de \
--to=tobias@stuttgart.de \
--cc=pbs-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