prune mark: correctly keep track of already included backups

This needs to happen in a separate loop, because some time intervals are not
subsets of others, i.e. weeks and months. Previously, with a daily backup
schedule, having:
* a backup on Sun, 06 Dec 2020 kept by keep-daily
* a backup on Sun, 29 Nov 2020 kept by keep-weekly
would lead to the backup on Mon, 30 Nov 2020 to be selected for keep-monthly,
because the iteration did not yet reach the backup on Sun, 29 Nov 2020 that
would mark November as being covered.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner
2020-12-14 15:03:17 +00:00
committed by Thomas Lamprecht
parent 44fdfb2af6
commit 10dfeb9ef0
2 changed files with 55 additions and 5 deletions

View File

@ -1646,13 +1646,14 @@ my $prune_mark = sub {
foreach my $prune_entry (@{$prune_entries}) {
my $mark = $prune_entry->{mark};
my $id = $id_func->($prune_entry->{ctime});
$already_included->{$id} = 1 if defined($mark) && $mark eq 'keep';
}
next if $already_included->{$id};
foreach my $prune_entry (@{$prune_entries}) {
my $mark = $prune_entry->{mark};
my $id = $id_func->($prune_entry->{ctime});
if (defined($mark)) {
$already_included->{$id} = 1 if $mark eq 'keep';
next;
}
next if defined($mark) || $already_included->{$id};
if (!$newly_included->{$id}) {
last if scalar(keys %{$newly_included}) >= $keep_count;