From b0b1fbd99a36f1fd3a40f7a25edf99d029667f40 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 31 Jan 2011 16:04:06 +0100 Subject: [PATCH] visit minimum number of backups for only_increment we need two increment and full or two full backups to correctly detect changes without this change every full backup was dumped with all content instead of increment --- lib/BackupPC/View.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/BackupPC/View.pm b/lib/BackupPC/View.pm index cfebe69..725ecfd 100644 --- a/lib/BackupPC/View.pm +++ b/lib/BackupPC/View.pm @@ -97,19 +97,32 @@ sub dirCache my $previous_increment_entry; my $increment_backupNum = $backupNum; # used in loop + my @visit_backup_ids; + my $i; + for ( $i = $m->{idx} ; $i >= 0 ; $i-- ) { + + # we need two incremental backups to detect changes + next if $m->{backups}[$i]{level} >= $level && $#visit_backup_ids > 0; + + push @visit_backup_ids, $i; + + # for first full backup we need another full to detect changes + last if $m->{backups}[$i]{level} == 0 && $#visit_backup_ids > 0; + } + warn "# visit_backup_ids = ",dump @visit_backup_ids; # # merge backups, starting at the requested one, and working # backwards until we get to level 0. # $m->{mergeNums} = []; - for ( $i = $m->{idx} ; $level > 0 && $i >= 0 ; $i-- ) { +# for ( $i = $m->{idx} ; $level > 0 && $i >= 0 ; $i-- ) { + for my $i ( @visit_backup_ids ) { #print(STDERR "Do $i ($m->{backups}[$i]{noFill},$m->{backups}[$i]{level})\n"); # # skip backups with the same or higher level # - #next if ( $m->{backups}[$i]{level} >= $level ); - # FIXME ASA skip all but first? + #next if ( $m->{backups}[$i]{level} >= $level ); # ASA - visit_backup_ids $level = $m->{backups}[$i]{level}; $backupNum = $m->{backups}[$i]{num}; -- 2.20.1