[pbs-devel] [PATCH proxmox-backup] fix #3336: api: remove backup group if the last snapshot is removed
Stefan Sterz
s.sterz at proxmox.com
Wed Mar 9 14:50:31 CET 2022
Signed-off-by: Stefan Sterz <s.sterz at proxmox.com>
---
pbs-datastore/src/datastore.rs | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index d416c8d8..623b7688 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -346,6 +346,28 @@ impl DataStore {
)
})?;
+ // check if this was the last snapshot and if so remove the group
+ if backup_dir
+ .group()
+ .list_backups(&self.base_path())?
+ .is_empty()
+ {
+ let group_path = self.group_path(backup_dir.group());
+ let _guard = proxmox_sys::fs::lock_dir_noblock(
+ &group_path,
+ "backup group",
+ "possible running backup",
+ )?;
+
+ std::fs::remove_dir_all(&group_path).map_err(|err| {
+ format_err!(
+ "removing backup group directory {:?} failed - {}",
+ group_path,
+ err,
+ )
+ })?;
+ }
+
// the manifest does not exists anymore, we do not need to keep the lock
if let Ok(path) = self.manifest_lock_path(backup_dir) {
// ignore errors
--
2.30.2
More information about the pbs-devel
mailing list