all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup] fix #7305: client: restore: filter out last snapshot if not finished
Date: Fri, 13 Feb 2026 11:43:04 +0100	[thread overview]
Message-ID: <20260213104304.375430-1-c.ebner@proxmox.com> (raw)

When invoking the client CLI for restore via:
```
proxmox-backup-client restore <snapshot> <archive> <target>
```
but <archive> providing a backup group only, the client falls back to
restore the last snapshot of that group for convenience.

The snapshot listing used to identify the last snapshot returns
however all snapshots, including unfinished ones, a restore on an
unfinished one will therefore fail.

Fix this by filtering the snapshot to be restored by checking the
presence of the manifest file and are therefore considered finished.
If the file is not present, skip the snapshot and try for the next
one, if any. Also adapt the helper function name to reflect this
change.

Ideally this would happen on the server side, guarded by some flag,
but that will not work with older server versions.

Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=7305
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 1:
- Skip any considered snapshot without manifest
- Refactor based on Fabian's suggestions

 proxmox-backup-client/src/main.rs | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 999e50205..10a864a0f 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -160,7 +160,7 @@ async fn api_datastore_list_snapshots(
     Ok(result["data"].take())
 }
 
-pub async fn api_datastore_latest_snapshot(
+pub async fn api_datastore_latest_finished_snapshot(
     client: &HttpClient,
     store: &str,
     ns: &BackupNamespace,
@@ -175,7 +175,30 @@ pub async fn api_datastore_latest_snapshot(
 
     list.sort_unstable_by(|a, b| b.backup.time.cmp(&a.backup.time));
 
-    Ok((group, list[0].backup.time).into())
+    let last_finished_time = list
+        .iter()
+        .find_map(|snapshot_item| {
+            // only once a snapshots contains the manifest it is considered finished
+            snapshot_item
+                .files
+                .iter()
+                .find_map(|content| {
+                    if content.filename == MANIFEST_BLOB_NAME.as_ref() {
+                        Some(snapshot_item.backup.time)
+                    } else {
+                        None
+                    }
+                })
+                .or_else(|| {
+                    log::info!("skipped not finished snapshot {}", snapshot_item.backup);
+                    None
+                })
+        })
+        .ok_or_else(|| {
+            format_err!("backup group {group} does not contain any finished snapshots.")
+        })?;
+
+    Ok((group, last_finished_time).into())
 }
 
 pub async fn dir_or_last_from_group(
@@ -187,7 +210,7 @@ pub async fn dir_or_last_from_group(
     match path.parse::<BackupPart>()? {
         BackupPart::Dir(dir) => Ok(dir),
         BackupPart::Group(group) => {
-            api_datastore_latest_snapshot(client, repo.store(), ns, group).await
+            api_datastore_latest_finished_snapshot(client, repo.store(), ns, group).await
         }
     }
 }
-- 
2.47.3





             reply	other threads:[~2026-02-13 10:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13 10:43 Christian Ebner [this message]
2026-02-13 10:45 ` Christian Ebner
2026-02-13 10:51 ` Fabian Grünbichler
  -- strict thread matches above, loose matches on Subject: below --
2026-02-11 15:24 Christian Ebner
2026-02-12 14:54 ` Fabian Grünbichler
2026-02-13  8:54   ` Christian Ebner

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=20260213104304.375430-1-c.ebner@proxmox.com \
    --to=c.ebner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal