datastore: prevent deletion of snaps in use as "previous backup"
To prevent a race with a background GC operation, do not allow deletion of backups who's index might currently be referenced as the "known chunk list" for successive backups. Otherwise the GC could delete chunks it thinks are no longer referenced, while at the same time telling the client that it doesn't need to upload said chunks because they already exist. Additionally, prevent deletion of whole backup groups, if there are snapshots contained that appear to be currently in-progress. This is currently unlikely to trigger, as that function is only used for sync jobs, but it's a useful safeguard either way. Deleting a single snapshot has a 'force' parameter, which is necessary to allow deleting incomplete snapshots on an aborted backup. Pruning also sets force=true to avoid the check, since it calculates which snapshots to keep on its own. To avoid code duplication, the is_finished method is factored out. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
8cd29fb24a
commit
c9756b40d1
@ -272,7 +272,7 @@ fn delete_snapshot(
|
||||
let allowed = (user_privs & PRIV_DATASTORE_MODIFY) != 0;
|
||||
if !allowed { check_backup_owner(&datastore, snapshot.group(), &username)?; }
|
||||
|
||||
datastore.remove_backup_dir(&snapshot)?;
|
||||
datastore.remove_backup_dir(&snapshot, false)?;
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
@ -661,7 +661,7 @@ fn prune(
|
||||
}));
|
||||
|
||||
if !(dry_run || keep) {
|
||||
datastore.remove_backup_dir(&info.backup_dir)?;
|
||||
datastore.remove_backup_dir(&info.backup_dir, true)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user