public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] verify/protect: improve error on disappearing snapshots
Date: Thu,  2 Feb 2023 14:04:24 +0100	[thread overview]
Message-ID: <20230202130424.3446075-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20230202130424.3446075-1-f.gruenbichler@proxmox.com>

or clients passing in a non-existent snapshot.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@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





  reply	other threads:[~2023-02-02 13:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 13:04 [pbs-devel] [PATCH proxmox-backup 1/2] backup/snapshot reader: improve error message for ENOENT Fabian Grünbichler
2023-02-02 13:04 ` Fabian Grünbichler [this message]
2023-02-08 14:22 ` [pbs-devel] applied-series: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202130424.3446075-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal