[pbs-devel] [PATCH v3 proxmox-backup 12/20] datastore: recover backup group from trash for new backups

Christian Ebner c.ebner at proxmox.com
Tue May 13 15:52:39 CEST 2025


A whole backup group might have been marked as trashed, including all
of the contained snapshots.

A new backup to the trashed group will only be allowed if owner and
user match, restoring the group. Otherwise, fail and do not allow
backups until the group is either removed from trash or permanently
cleared.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 6f99ff572..1bc096420 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -28,7 +28,7 @@ use pbs_api_types::{
 };
 use pbs_config::BackupLockGuard;
 
-use crate::backup_info::{BackupDir, BackupGroup, BackupInfo, OLD_LOCKING};
+use crate::backup_info::{BackupDir, BackupGroup, BackupInfo, OLD_LOCKING, TRASH_MARKER_FILENAME};
 use crate::chunk_store::ChunkStore;
 use crate::dynamic_index::{DynamicIndexReader, DynamicIndexWriter};
 use crate::fixed_index::{FixedIndexReader, FixedIndexWriter};
@@ -809,6 +809,16 @@ impl DataStore {
                 let guard = backup_group.lock().with_context(|| {
                     format!("while creating locked backup group '{backup_group:?}'")
                 })?;
+                if backup_group.is_trash() {
+                    let owner = self.get_owner(ns, backup_group.group())?;
+                    check_backup_owner(&owner, auth_id)?;
+                    info!("remove trash marker for backup group {full_path:?}");
+                    let trash_path = full_path.join(TRASH_MARKER_FILENAME);
+                    std::fs::remove_file(trash_path)
+                        .context("failed to remove trash marker file")?;
+                    return Ok((owner, guard));
+                }
+
                 let owner = self.get_owner(ns, backup_group.group())?; // just to be sure
                 Ok((owner, guard))
             }
-- 
2.39.5





More information about the pbs-devel mailing list