From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EA66020EC91 for ; Tue, 30 Apr 2024 15:40:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1D4C934F70; Tue, 30 Apr 2024 15:40:22 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 30 Apr 2024 15:39:57 +0200 Message-Id: <20240430133957.304866-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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. [proxmox.com, main.rs] Subject: [pbs-devel] [PATCH proxmox-backup] fix #2996: client: allow optional match pattens for restore 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" When the user is only interested in a subset of the entries stored in a file-level backup, it is convenient to be able to provide a list of match patterns for the entries intended to be restored. The required restore logic is already in place. Therefore, expose it for the `proxmox-backup-client restore` command by adding the optional array of patterns as command line argument and parse these before passing them via the pxar restore options to the archive extractor. Link to bugtracker issue: https://bugzilla.proxmox.com/show_bug.cgi?id=2996 Signed-off-by: Christian Ebner --- proxmox-backup-client/src/main.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index 32fe914c4..1f1dac151 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -1186,6 +1186,15 @@ We do not extract '.pxar' archives when writing to standard output. "### }, + "matches": { + type: Array, + description: "Only restore entries matching given paths or patterns.", + optional: true, + items: { + type: String, + description: "Path or match pattern.", + }, + }, rate: { schema: TRAFFIC_CONTROL_RATE_SCHEMA, optional: true, @@ -1306,6 +1315,20 @@ async fn restore( let target = json::required_string_param(¶m, "target")?; let target = if target == "-" { None } else { Some(target) }; + let mut match_list = Vec::new(); + if let Some(patterns) = param["matches"].as_array() { + for pattern in patterns { + if let Some(pattern) = pattern.as_str() { + let match_entry = MatchEntry::parse_pattern( + pattern, + PatternFlag::PATH_NAME, + MatchType::Include + )?; + match_list.push(match_entry); + } + } + }; + let crypto = crypto_parameters(¶m)?; let crypt_config = match crypto.enc_key { @@ -1429,8 +1452,8 @@ async fn restore( } let options = pbs_client::pxar::PxarExtractOptions { - match_list: &[], - extract_match_default: true, + match_list: match_list.as_slice(), + extract_match_default: match_list.is_empty(), allow_existing_dirs, overwrite_flags, on_error, -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel