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 0CA781FF0B7 for ; Fri, 13 Nov 2026 10:07:22 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6E36B21879; Fri, 13 Nov 2026 10:06:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stuttgart.de; s=s1022; t=1794560286; bh=ZfH0LUPyfpfsdjlkd9sNhETYCOvBJ4iKqikpzPuxHwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ki5+IhXL1BZj9JLMhIfmv5AaWCrmIn2m9LeyNuO7aVnE4t4QnbWnhJ2lAODKHe5iD 2YzvaWy9wOF5/nThDYmCLb9bt9PQ9Qtq6v+qgBtXOskFtRndjMCgvwzUkB1QYmghmX 4ri+DUrJr+e7CWGoGUMRJ95yjQIR+RKtLwKdDxSDXZO2QvHl+v2ChBEkqLZx8aRyF7 GzAVn2arq8x+/LKiNr6BznPXRfy1jvePm16sc99M/2cPrXMB6NsnkEPcwlmMyLHdh8 Z7yRKw/+IN81fxI5hYSRHUeLC1SPgEkn9KBmcq/OZpDoaC+VKoA2UYFqSsWLSP62d2 3OQMvyI13RJow== From: Jakob-Tobias Winter To: pbs-devel@lists.proxmox.com Subject: [RFC PATCH storage 08/12] pbs: add helper to set the attributes of a backup snapshot Date: Fri, 13 Nov 2026 09:56:35 +0100 Message-ID: <20261113085637.57360-11-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.023 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: DPRBA6YPOP64X62XRJJGK4UA6DBR6QI4 X-Message-ID-Hash: DPRBA6YPOP64X62XRJJGK4UA6DBR6QI4 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: Proxmox Backup Server can store attributes for a backup snapshot, keys with a list of values, for information about the source of a backup which the server cannot know on its own. Add a helper to set them, so that vzdump can store the tags and the resource pool of a guest with its backups. It talks to the API of the server directly, like the code for the protection flag, to not depend on the version of the installed backup client. A server which does not support snapshot attributes yet is not an error. The helper tells the caller instead, so that backups to older servers keep working without warnings. The attributes are specific to Proxmox Backup Server, so this is not made part of the storage plugin API. Signed-off-by: Jakob-Tobias Winter --- src/PVE/Storage/PBSPlugin.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm index 6adafa3..107b13d 100644 --- a/src/PVE/Storage/PBSPlugin.pm +++ b/src/PVE/Storage/PBSPlugin.pm @@ -959,6 +959,29 @@ sub update_volume_attribute { die "attribute '$attribute' is not supported for storage type '$scfg->{type}'\n"; } +# Replace the attributes of a backup snapshot on the Proxmox Backup Server. +# +# Expects a list of 'KEY=VALUE' strings, a key with several values is passed once for each value. +# Returns false if the server is not recent enough to support snapshot attributes. +sub update_snapshot_attributes { + my ($class, $scfg, $storeid, $volname, $attributes) = @_; + + my $param = api_param_from_volname($class, $scfg, $volname); + $param->{attributes} = $attributes; + + my $password = pbs_get_password($scfg, $storeid); + my $conn = pbs_api_connect($scfg, $password); + my $datastore = $scfg->{datastore}; + + eval { $conn->put("/api2/json/admin/datastore/$datastore/attributes", $param); }; + if (my $err = $@) { + return 0 if ref($err) && $err->{code} == 404; # not supported + die $err; + } + + return 1; +} + sub volume_size_info { my ($class, $scfg, $storeid, $volname, $timeout) = @_; base-commit: 50bbabb4d6cec50d5b049f0b7a49f1a87dbdc30e -- 2.53.0