From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 628AC1FF0C0 for ; Wed, 18 Nov 2026 14:07:04 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id CADAC2168A; Wed, 18 Nov 2026 14:07:03 +0100 (CET) Message-ID: <0ab4a114-3946-4855-842f-9a6dfb5ae1bf@proxmox.com> Date: Wed, 18 Nov 2026 14:06:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Samuel Rufinatscha Subject: Re: [RFC PATCH proxmox-backup 05/12] tape: backup job: allow selecting groups by snapshot attributes To: Jakob-Tobias Winter , pbs-devel@lists.proxmox.com References: <20261113085637.57360-3-tobias@stuttgart.de> <20261113085637.57360-8-tobias@stuttgart.de> Content-Language: en-US In-Reply-To: <20261113085637.57360-8-tobias@stuttgart.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.160 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: JOZ23GKD65PYPZSSSO7T4X7DIL3ARYIJ X-Message-ID-Hash: JOZ23GKD65PYPZSSSO7T4X7DIL3ARYIJ X-MailFrom: s.rufinatscha@proxmox.com 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 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: On 11/13/26 10:06 AM, Jakob-Tobias Winter wrote: > Tape backup jobs can only select backup groups by type and ID so > far. Such filters have to be kept up to date by hand for every new > guest, and an ID says nothing about how important a guest is. > > Add an attribute filter to tape backup jobs. With a client which > stores the tags of a guest as snapshot attributes, production and > test guests can be written to different media pools with different > retention policies, by using one job for each media pool. The media > sets of the production guests then need fewer tapes and are faster > to restore. > > A group is included if it has one of the attributes given as include > filter, or if there are no include filters, and none of the > attributes given as exclude filter. The filter is applied in > addition to the group filter. > > Jobs without an attribute filter select the same groups as before. > > Signed-off-by: Jakob-Tobias Winter > --- > A version without this patch cannot parse a tape-job.cfg in which the > new option is used (unknown property 'attribute-filter'). > > src/api2/config/tape_backup_job.rs | 8 ++++++++ > src/api2/tape/backup.rs | 19 ++++++++++++++++--- > src/bin/proxmox-tape.rs | 11 ++++++++--- > 3 files changed, 32 insertions(+), 6 deletions(-) > > diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs > index 4bfc7f871..cb9e63ea6 100644 > --- a/src/api2/config/tape_backup_job.rs > +++ b/src/api2/config/tape_backup_job.rs > @@ -144,6 +144,8 @@ pub enum DeletableProperty { > NotificationMode, > /// Delete the 'group_filter' property > GroupFilter, > + /// Delete the 'attribute-filter' property > + AttributeFilter, > /// Delete the 'max-depth' property > MaxDepth, > /// Delete the 'ns' property > @@ -227,6 +229,9 @@ pub fn update_tape_backup_job( > DeletableProperty::GroupFilter => { > data.setup.group_filter = None; > } > + DeletableProperty::AttributeFilter => { > + data.setup.attribute_filter = None; > + } > DeletableProperty::MaxDepth => { > data.setup.max_depth = None; > } > @@ -268,6 +273,9 @@ pub fn update_tape_backup_job( > if update.setup.group_filter.is_some() { > data.setup.group_filter = update.setup.group_filter; > } > + if update.setup.attribute_filter.is_some() { > + data.setup.attribute_filter = update.setup.attribute_filter; > + } > if update.setup.ns.is_some() { > data.setup.ns = update.setup.ns; > } > diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs > index c0a4ca65b..c2797a97a 100644 > --- a/src/api2/tape/backup.rs > +++ b/src/api2/tape/backup.rs > @@ -11,9 +11,9 @@ use proxmox_schema::api; > use proxmox_worker_task::WorkerTaskContext; > > use pbs_api_types::{ > - Authid, JOB_ID_SCHEMA, MediaPoolConfig, Operation, PRIV_TAPE_AUDIT, TapeBackupJobConfig, > - TapeBackupJobSetup, TapeBackupJobStatus, UPID_SCHEMA, print_ns_and_snapshot, > - print_store_and_ns, > + AttributeFilter, Authid, JOB_ID_SCHEMA, MediaPoolConfig, Operation, PRIV_TAPE_AUDIT, > + TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, UPID_SCHEMA, > + print_ns_and_snapshot, print_store_and_ns, > }; > > use pbs_config::CachedUserInfo; > @@ -391,6 +391,19 @@ fn backup_worker( > None => group_list, > }; > > + let group_list = match &setup.attribute_filter { > + Some(filters) => { > + let mut filtered = Vec::new(); > + for group in group_list { > + if AttributeFilter::apply_filters(filters, &group.attributes()?) { once we filter for individual snapshots as suggested by @Christian, how should latest-only behave? For example, if monday and tuesday are tagged with "test" and wednesday is tagged with "prod", should a test job copy the tuesday snapshot or skip the group because the latest backup in the group is on "prod"? I would lean towards copying tuesday’s snapshot in this example since it’s the newest one and it matches the job’s filter > + filtered.push(group); > + } > + } > + filtered > + } > + None => group_list, > + }; > + > info!( > "found {} groups (out of {group_count_full} total)", > group_list.len() > diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs > index dcbf2d0fb..6ea46b709 100644 > --- a/src/bin/proxmox-tape.rs > +++ b/src/bin/proxmox-tape.rs > @@ -19,9 +19,10 @@ use pbs_config::drive::complete_drive_name; > use pbs_config::media_pool::complete_pool_name; > > use pbs_api_types::{ > - Authid, BackupNamespace, DATASTORE_MAP_LIST_SCHEMA, DATASTORE_SCHEMA, DRIVE_NAME_SCHEMA, > - GROUP_FILTER_LIST_SCHEMA, GroupListItem, MEDIA_LABEL_SCHEMA, MEDIA_POOL_NAME_SCHEMA, > - NS_MAX_DEPTH_SCHEMA, TAPE_RESTORE_NAMESPACE_SCHEMA, TAPE_RESTORE_SNAPSHOT_SCHEMA, Userid, > + ATTRIBUTE_FILTER_LIST_SCHEMA, Authid, BackupNamespace, DATASTORE_MAP_LIST_SCHEMA, > + DATASTORE_SCHEMA, DRIVE_NAME_SCHEMA, GROUP_FILTER_LIST_SCHEMA, GroupListItem, > + MEDIA_LABEL_SCHEMA, MEDIA_POOL_NAME_SCHEMA, NS_MAX_DEPTH_SCHEMA, TAPE_RESTORE_NAMESPACE_SCHEMA, > + TAPE_RESTORE_SNAPSHOT_SCHEMA, Userid, > }; > use pbs_tape::{BlockReadError, MediaContentHeader, PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0}; > > @@ -850,6 +851,10 @@ async fn clean_drive(mut param: Value) -> Result<(), Error> { > schema: GROUP_FILTER_LIST_SCHEMA, > optional: true, > }, > + "attribute-filter": { > + schema: ATTRIBUTE_FILTER_LIST_SCHEMA, > + optional: true, > + }, > ns: { > type: BackupNamespace, > optional: true,