[pbs-devel] [PATCH proxmox-backup] api2/tape/backup: continue on vanishing snapshots

Dominik Csapak d.csapak at proxmox.com
Tue Mar 9 09:43:06 CET 2021


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 <d.csapak at proxmox.com>
---
 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<DataStore>,
     snapshot: BackupDir,
-) -> Result<(), Error> {
+) -> Result<bool, Error> {
 
     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






More information about the pbs-devel mailing list