From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9BBF97C223 for ; Thu, 4 Nov 2021 10:56:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 931D01DD6D for ; Thu, 4 Nov 2021 10:56:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id A3D151DD5F for ; Thu, 4 Nov 2021 10:56:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7A602469D6 for ; Thu, 4 Nov 2021 10:56:26 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 4 Nov 2021 10:56:20 +0100 Message-Id: <20211104095622.2207427-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211104095622.2207427-1-d.csapak@proxmox.com> References: <20211104095622.2207427-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.246 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backup.rs] Subject: [pbs-devel] [PATCH proxmox-backup 3/5] fix #3533: tape backup: filter groups according to config X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2021 09:56:57 -0000 this fixes bug #3533, since now a user can backup a single datastore on multiple tape media pools in parallel, e.g. vms on one pool, ct on another. Signed-off-by: Dominik Csapak --- src/api2/tape/backup.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index a0578391..1d775459 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -11,10 +11,11 @@ use proxmox_schema::api; use pbs_api_types::{ Authid, Userid, TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, MediaPoolConfig, UPID_SCHEMA, JOB_ID_SCHEMA, PRIV_DATASTORE_READ, PRIV_TAPE_AUDIT, PRIV_TAPE_WRITE, + GroupFilter, }; use pbs_datastore::{DataStore, StoreProgress, SnapshotReader}; -use pbs_datastore::backup_info::{BackupDir, BackupInfo}; +use pbs_datastore::backup_info::{BackupDir, BackupInfo, BackupGroup}; use pbs_tools::{task_log, task_warn, task::WorkerTaskContext}; use pbs_config::CachedUserInfo; use proxmox_rest_server::WorkerTask; @@ -436,8 +437,21 @@ fn backup_worker( group_list.sort_unstable(); - let group_count = group_list.len(); - task_log!(worker, "found {} groups", group_count); + let (group_list, group_count) = if let Some(group_filters) = &setup.groups { + let filter_fn = |group: &BackupGroup, group_filters: &[GroupFilter]| { + group_filters.iter().any(|filter| group.matches(filter)) + }; + + let group_count_full = group_list.len(); + let list: Vec = group_list.into_iter().filter(|group| filter_fn(group, &group_filters)).collect(); + let group_count = list.len(); + task_log!(worker, "found {} groups (out of {} total)", group_count, group_count_full); + (list, group_count) + } else { + let group_count = group_list.len(); + task_log!(worker, "found {} groups", group_count); + (group_list, group_count) + }; let mut progress = StoreProgress::new(group_count as u64); -- 2.30.2