pbs-datastore: skip protected backups in pruning

as a separate keep reason so it will not be calculated for the other reasons

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-10-27 13:22:27 +02:00 committed by Wolfgang Bumiller
parent 92c5cf42d1
commit db4b469285
1 changed files with 5 additions and 1 deletions

View File

@ -7,7 +7,7 @@ use pbs_api_types::PruneOptions;
use super::BackupInfo; use super::BackupInfo;
enum PruneMark { Keep, KeepPartial, Remove } enum PruneMark { Protected, Keep, KeepPartial, Remove }
fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>> ( fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>> (
mark: &mut HashMap<PathBuf, PruneMark>, mark: &mut HashMap<PathBuf, PruneMark>,
@ -30,6 +30,10 @@ fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>> (
for info in list { for info in list {
let backup_id = info.backup_dir.relative_path(); let backup_id = info.backup_dir.relative_path();
if mark.get(&backup_id).is_some() { continue; } if mark.get(&backup_id).is_some() { continue; }
if info.protected {
mark.insert(backup_id, PruneMark::Protected);
continue;
}
let sel_id: String = select_id(&info)?; let sel_id: String = select_id(&info)?;
if already_included.contains(&sel_id) { continue; } if already_included.contains(&sel_id) { continue; }