From c78437e320925913418f235811fe3c54ac95b1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 2 Feb 2023 14:04:24 +0100 Subject: [PATCH] verify/protect: improve error on disappearing snapshots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit or clients passing in a non-existent snapshot. Signed-off-by: Fabian Grünbichler --- 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 6f37e886a..bf9513053 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 3984e28dc..c972e5328 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 { + 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",