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 45C811FF0B7 for ; Fri, 13 Nov 2026 10:06:10 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 019E621765; 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=5frSxXfUYMpKf+Ps601KfTASu7Jb5GLUmnHEx9VFmOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxBwMgOGMVX0R06A1TyhSLvp2BaawzqI+uBGLyuJTNjYrx4wWjy+HiVE7j0WSa72K goCLBOnFNfFysCBIN/yePCfyPnHNDxKTUIew8zRPXQ2mej0f28F3iKgJ1Ac0eUdaH+ 2cxMTUA0wqDRxRf2jN5JK+a0Sixz6XPxcqrcGpi4YG/qN8tR5ZemGUPOX7mHFwfeou WTo/MMYFX+xRkCWY2xo980cqzPPchn2eXrMUReSe8E5kQbdlxN1amjmq10yAehRFhZ uXbeXumxkTb9D814YMOR5DSjmU6XKkOsYWWjir+6Lrfm04vCb0Hbl+fTKr1Q2Vol0U yBnuX3JTYZceg== From: Jakob-Tobias Winter To: pbs-devel@lists.proxmox.com Subject: [RFC PATCH proxmox-backup 05/12] tape: backup job: allow selecting groups by snapshot attributes Date: Fri, 13 Nov 2026 09:56:32 +0100 Message-ID: <20261113085637.57360-8-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.025 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: DGPLAUHOPL4MGLTVCXT6UBHXVSOTFPDI X-Message-ID-Hash: DGPLAUHOPL4MGLTVCXT6UBHXVSOTFPDI 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: 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()?) { + 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, -- 2.53.0