public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] fix #3336: api: remove backup group if the last snapshot is removed
@ 2022-03-09 13:50 Stefan Sterz
  2022-03-11 12:20 ` Thomas Lamprecht
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Sterz @ 2022-03-09 13:50 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Stefan Sterz <s.sterz@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





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-03-14 17:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 13:50 [pbs-devel] [PATCH proxmox-backup] fix #3336: api: remove backup group if the last snapshot is removed Stefan Sterz
2022-03-11 12:20 ` Thomas Lamprecht
2022-03-14  9:36   ` Wolfgang Bumiller
2022-03-14 10:19     ` Thomas Lamprecht
2022-03-14 11:13       ` Stefan Sterz
2022-03-14 11:36         ` Thomas Lamprecht
2022-03-14 14:18           ` Stefan Sterz
2022-03-14 14:53             ` Thomas Lamprecht
2022-03-14 15:19               ` Stefan Sterz
2022-03-14 17:12                 ` Thomas Lamprecht

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