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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 25DA16B3F8 for ; Tue, 9 Mar 2021 09:43:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0FEBF26F79 for ; Tue, 9 Mar 2021 09:43:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 7F8C226F71 for ; Tue, 9 Mar 2021 09:43:08 +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 4ECF844CBA for ; Tue, 9 Mar 2021 09:43:08 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 9 Mar 2021 09:43:06 +0100 Message-Id: <20210309084306.5791-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.195 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 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] api2/tape/backup: continue on vanishing snapshots 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: Tue, 09 Mar 2021 08:43:39 -0000 when we do a prune during a tape backup, do not cancel the tape backup, but continue with a warning the task still fails and prompts the user to check the log Signed-off-by: Dominik Csapak --- src/api2/tape/backup.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index e8ae887c..8efe1481 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -16,6 +16,7 @@ use proxmox::{ use crate::{ task_log, + task_warn, config::{ self, cached_user_info::CachedUserInfo, @@ -395,6 +396,8 @@ fn backup_worker( task_log!(worker, "latest-only: true (only considering latest snapshots)"); } + let mut errors = false; + for group in group_list { let mut snapshot_list = group.list_backups(&datastore.base_path())?; @@ -406,7 +409,9 @@ fn backup_worker( continue; } task_log!(worker, "backup snapshot {}", info.backup_dir); - backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)?; + if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? { + errors = true; + } } } else { for info in snapshot_list { @@ -414,7 +419,9 @@ fn backup_worker( continue; } task_log!(worker, "backup snapshot {}", info.backup_dir); - backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)?; + if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? { + errors = true; + } } } } @@ -427,6 +434,10 @@ fn backup_worker( pool_writer.eject_media(worker)?; } + if errors { + bail!("Tape backup finished with some errors. Please check the task log."); + } + Ok(()) } @@ -460,11 +471,18 @@ pub fn backup_snapshot( pool_writer: &mut PoolWriter, datastore: Arc, snapshot: BackupDir, -) -> Result<(), Error> { +) -> Result { task_log!(worker, "start backup {}:{}", datastore.name(), snapshot); - let snapshot_reader = SnapshotReader::new(datastore.clone(), snapshot.clone())?; + let snapshot_reader = match SnapshotReader::new(datastore.clone(), snapshot.clone()) { + Ok(reader) => reader, + Err(err) => { + // ignore missing snapshots and continue + task_warn!(worker, "failed opening snapshot '{}': {}", snapshot, err); + return Ok(false); + } + }; let mut chunk_iter = snapshot_reader.chunk_iterator()?.peekable(); @@ -511,5 +529,5 @@ pub fn backup_snapshot( task_log!(worker, "end backup {}:{}", datastore.name(), snapshot); - Ok(()) + Ok(true) } -- 2.20.1