From 4c0ae82e23fae1431b061f58bf7037466bd8e43f Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Wed, 14 Oct 2020 14:16:37 +0200 Subject: [PATCH] datastore: remove individual snapshots before group 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 --- src/backup/datastore.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index 95adc872..7dd2624c 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -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, ) -- 2.39.2