[pbs-devel] [RFC v2 proxmox-backup 13/21] datastore: recreate trashed backup groups if requested
Christian Ebner
c.ebner at proxmox.com
Thu May 8 15:05:47 CEST 2025
A whole backup group might have been marked as trashed, including all
of the contained snapshots.
Since a new backup to that group (even as different user/owner)
should still work, permanently clear the whole trashed group before
recreation. This will limit the trash lifetime as now the group is
not recoverable until next garbage collection.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
pbs-datastore/src/datastore.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 4f7766c36..ca05e1bea 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -934,6 +934,32 @@ impl DataStore {
let guard = backup_group.lock().with_context(|| {
format!("while creating locked backup group '{backup_group:?}'")
})?;
+ if backup_group.is_trashed() {
+ info!("clear trashed backup group {full_path:?}");
+ let dir_entries = std::fs::read_dir(&full_path).context(
+ "failed to read directory contents during cleanup of trashed group",
+ )?;
+ for entry in dir_entries {
+ let entry = entry.context(
+ "failed to read directory entry during clenup of trashed group",
+ )?;
+ let file_type = entry.file_type().context(
+ "failed to get entry file type during clenup of trashed group",
+ )?;
+ if file_type.is_dir() {
+ std::fs::remove_dir_all(entry.path())
+ .context("failed to remove directory entry during clenup of trashed snapshot")?;
+ } else {
+ std::fs::remove_file(entry.path())
+ .context("failed to remove directory entry during clenup of trashed snapshot")?;
+ }
+ }
+ self.set_owner(ns, backup_group.group(), auth_id, false)?;
+ let owner = self.get_owner(ns, backup_group.group())?; // just to be sure
+ self.untrash_namespace(ns)?;
+ 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