[pbs-devel] [PATCH proxmox-backup 2/2] verify/protect: improve error on disappearing snapshots

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Feb 2 14:04:24 CET 2023


or clients passing in a non-existent snapshot.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 pbs-datastore/src/datastore.rs |  4 ++++
 src/backup/verify.rs           | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 6f37e886..bf951305 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1180,6 +1180,10 @@ impl DataStore {
     pub fn update_protection(&self, backup_dir: &BackupDir, protection: bool) -> Result<(), Error> {
         let full_path = backup_dir.full_path();
 
+        if !full_path.exists() {
+            bail!("snapshot {} does not exist!", backup_dir.dir());
+        }
+
         let _guard = lock_dir_noblock(&full_path, "snapshot", "possibly running or in use")?;
 
         let protected_path = backup_dir.protected_file();
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index 3984e28d..c972e532 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -328,6 +328,16 @@ pub fn verify_backup_dir(
     upid: UPID,
     filter: Option<&dyn Fn(&BackupManifest) -> bool>,
 ) -> Result<bool, Error> {
+    if !backup_dir.full_path().exists() {
+        task_log!(
+            verify_worker.worker,
+            "SKIPPED: verify {}:{} - snapshot does not exist (anymore).",
+            verify_worker.datastore.name(),
+            backup_dir.dir(),
+        );
+        return Ok(true);
+    }
+
     let snap_lock = lock_dir_noblock_shared(
         &backup_dir.full_path(),
         "snapshot",
-- 
2.30.2






More information about the pbs-devel mailing list