]> git.proxmox.com Git - proxmox-backup.git/commitdiff
datastore: remove individual snapshots before group
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 14 Oct 2020 12:16:37 +0000 (14:16 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 15 Oct 2020 05:51:09 +0000 (07:51 +0200)
Removing a snapshot has some more safety checks which we don't want to
ignore when removing an entire group (i.e. locking the manifest and
notifying GC).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/backup/datastore.rs

index 95adc87263b1c0ef5a764a7627ae1c3b255a6645..7dd2624c825dfff4e528f40a837607d7997455e7 100644 (file)
@@ -207,10 +207,17 @@ impl DataStore {
         let _guard = tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
 
         log::info!("removing backup group {:?}", full_path);
+
+        // remove all individual backup dirs first to ensure nothing is using them
+        for snap in backup_group.list_backups(&self.base_path())? {
+            self.remove_backup_dir(&snap.backup_dir, false)?;
+        }
+
+        // no snapshots left, we can now safely remove the empty folder
         std::fs::remove_dir_all(&full_path)
             .map_err(|err| {
                 format_err!(
-                    "removing backup group {:?} failed - {}",
+                    "removing backup group directory {:?} failed - {}",
                     full_path,
                     err,
                 )