From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D4A5C1FF38E for ; Tue, 28 May 2024 11:51:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DE4E2136FC; Tue, 28 May 2024 11:52:14 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 28 May 2024 11:42:18 +0200 Message-Id: <20240528094303.309806-25-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240528094303.309806-1-c.ebner@proxmox.com> References: <20240528094303.309806-1-c.ebner@proxmox.com> 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [main.rs] Subject: [pbs-devel] [PATCH v8 proxmox-backup 24/69] client: restore: read payload from dedicated index 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" Whenever a split pxar archive is encountered, instantiate and attach the required dedicated reader instance to the decoder instance on restore. Piping the output to stdout is not possible for these, as this would require a decoder instance which can decode the input stream, while maintaining the pxar stream format as output. Signed-off-by: Christian Ebner --- changes since version 7: - no changes changes since version 6: - adapt to PxarVariant pxar interface - use newly introduced has_pxar_filename_extension - allow for pxar -> mpxar mapping proxmox-backup-client/src/main.rs | 45 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index db0fb6324..ef481743f 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -35,7 +35,7 @@ use pbs_client::tools::{ complete_archive_name, complete_auth_id, complete_backup_group, complete_backup_snapshot, complete_backup_source, complete_chunk_size, complete_group_or_snapshot, complete_img_archive_name, complete_namespace, complete_pxar_archive_name, complete_repository, - connect, connect_rate_limited, extract_repository_from_value, + connect, connect_rate_limited, extract_repository_from_value, has_pxar_filename_extension, key_source::{ crypto_parameters, format_key_source, get_encryption_key_password, KEYFD_SCHEMA, KEYFILE_SCHEMA, MASTER_PUBKEY_FD_SCHEMA, MASTER_PUBKEY_FILE_SCHEMA, @@ -1216,7 +1216,7 @@ async fn dump_image( fn parse_archive_type(name: &str) -> (String, ArchiveType) { if name.ends_with(".didx") || name.ends_with(".fidx") || name.ends_with(".blob") { (name.into(), archive_type(name).unwrap()) - } else if name.ends_with(".pxar") { + } else if has_pxar_filename_extension(name, false) { (format!("{}.didx", name), ArchiveType::DynamicIndex) } else if name.ends_with(".img") { (format!("{}.fidx", name), ArchiveType::FixedIndex) @@ -1400,6 +1400,9 @@ async fn restore( let (manifest, backup_index_data) = client.download_manifest().await?; + let (archive_name, payload_archive_name) = + helper::get_pxar_archive_names(&archive_name, &manifest); + if archive_name == ENCRYPTED_KEY_BLOB_NAME && crypt_config.is_none() { log::info!("Restoring encrypted key blob without original key - skipping manifest fingerprint check!") } else { @@ -1450,20 +1453,13 @@ async fn restore( .map_err(|err| format_err!("unable to pipe data - {}", err))?; } } else if archive_type == ArchiveType::DynamicIndex { - let index = client - .download_dynamic_index(&manifest, &archive_name) - .await?; - - let most_used = index.find_most_used_chunks(8); - - let chunk_reader = RemoteChunkReader::new( + let mut reader = get_buffered_pxar_reader( + &archive_name, client.clone(), - crypt_config, - file_info.chunk_crypt_mode(), - most_used, - ); - - let mut reader = BufferedDynamicReader::new(index, chunk_reader); + &manifest, + crypt_config.clone(), + ) + .await?; let on_error = if ignore_extract_device_errors { let handler: PxarErrorHandler = Box::new(move |err: Error| { @@ -1518,8 +1514,22 @@ async fn restore( } if let Some(target) = target { + let reader = if let Some(payload_archive_name) = payload_archive_name { + let payload_reader = get_buffered_pxar_reader( + &payload_archive_name, + client.clone(), + &manifest, + crypt_config.clone(), + ) + .await?; + pxar::PxarVariant::Split(reader, payload_reader) + } else { + pxar::PxarVariant::Unified(reader) + }; + let decoder = pxar::decoder::Decoder::from_std(reader)?; + pbs_client::pxar::extract_archive( - pxar::decoder::Decoder::from_std(pxar::PxarVariant::Unified(reader))?, + decoder, Path::new(target), feature_flags, |path| { @@ -1529,6 +1539,9 @@ async fn restore( ) .map_err(|err| format_err!("error extracting archive - {:#}", err))?; } else { + if archive_name.ends_with(".mpxar.didx") || archive_name.ends_with(".ppxar.didx") { + bail!("unable to pipe split archive"); + } let mut writer = std::fs::OpenOptions::new() .write(true) .open("/dev/stdout") -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel