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 <s.reiter@proxmox.com>
This commit is contained in:
parent
883aa6d5a4
commit
4c0ae82e23
@ -207,10 +207,17 @@ impl DataStore {
|
|||||||
let _guard = tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
let _guard = tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
||||||
|
|
||||||
log::info!("removing backup group {:?}", full_path);
|
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)
|
std::fs::remove_dir_all(&full_path)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
format_err!(
|
format_err!(
|
||||||
"removing backup group {:?} failed - {}",
|
"removing backup group directory {:?} failed - {}",
|
||||||
full_path,
|
full_path,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user