src/backup/backup_info.rs - compute_prune_list: remove unfinished backups
This commit is contained in:
parent
6b9f395f31
commit
9ce42759ec
@ -86,6 +86,9 @@ fn upgrade_to_backup_protocol(
|
|||||||
if backup_dir.backup_time() <= last.backup_dir.backup_time() {
|
if backup_dir.backup_time() <= last.backup_dir.backup_time() {
|
||||||
bail!("backup timestamp is older than last backup.");
|
bail!("backup timestamp is older than last backup.");
|
||||||
}
|
}
|
||||||
|
// fixme: abort if last backup is still running - howto test?
|
||||||
|
// Idea: write upid into a file inside snapshot dir. then test if
|
||||||
|
// it is still running here.
|
||||||
}
|
}
|
||||||
|
|
||||||
let (path, is_new) = datastore.create_backup_dir(&backup_dir)?;
|
let (path, is_new) = datastore.create_backup_dir(&backup_dir)?;
|
||||||
|
@ -141,13 +141,29 @@ impl BackupGroup {
|
|||||||
|
|
||||||
BackupInfo::sort_list(&mut list, false);
|
BackupInfo::sort_list(&mut list, false);
|
||||||
|
|
||||||
if let Some(keep_last) = keep_last {
|
// remove inclomplete snapshots
|
||||||
for _ in 0..keep_last {
|
let mut keep_unfinished = true;
|
||||||
if list.is_empty() { break; }
|
for info in list.iter() {
|
||||||
let info = list.remove(0);
|
// backup is considered unfinished if there is no manifest
|
||||||
|
if info.files.iter().any(|name| name == super::MANIFEST_BLOB_NAME) {
|
||||||
|
// There is a new finished backup, so there is no need
|
||||||
|
// to keep older unfinished backups.
|
||||||
|
keep_unfinished = false;
|
||||||
|
} else {
|
||||||
let backup_id = info.backup_dir.relative_path();
|
let backup_id = info.backup_dir.relative_path();
|
||||||
|
if keep_unfinished { // keep first unfinished
|
||||||
mark.insert(backup_id, PruneMark::Keep);
|
mark.insert(backup_id, PruneMark::Keep);
|
||||||
|
} else {
|
||||||
|
mark.insert(backup_id, PruneMark::Remove);
|
||||||
}
|
}
|
||||||
|
keep_unfinished = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(keep_last) = keep_last {
|
||||||
|
Self::mark_selections(&mut mark, &list, keep_last as usize, |_local_time, info| {
|
||||||
|
BackupDir::backup_time_to_string(info.backup_dir.backup_time)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(keep_daily) = keep_daily {
|
if let Some(keep_daily) = keep_daily {
|
||||||
|
Loading…
Reference in New Issue
Block a user