X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FView.pm;h=b47080d2418581539acfabe71bafd5e9234e89ae;hp=3824bb4739a1bdb707094c7061e94d1c6d659d35;hb=HEAD;hpb=f6fbcc3682d2bc9e7dfdc26e95bd5fcdb359496d diff --git a/lib/BackupPC/View.pm b/lib/BackupPC/View.pm index 3824bb4..b47080d 100644 --- a/lib/BackupPC/View.pm +++ b/lib/BackupPC/View.pm @@ -13,7 +13,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2002-2007 Craig Barratt +# Copyright (C) 2002-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ # #======================================================================== # -# Version 3.2.0beta0, released 5 April 2009. +# Version 3.2.0, released 31 Jul 2010. # # See http://backuppc.sourceforge.net. # @@ -48,6 +48,8 @@ use BackupPC::FileZIO; use Data::Dumper; use Encode qw/from_to/; +use Data::Dump qw(dump); + sub new { my($class, $bpc, $host, $backups, $options) = @_; @@ -93,17 +95,34 @@ sub dirCache $m->{share} = $share; $m->{dir} = $dir; + 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 ); + #next if ( $m->{backups}[$i]{level} >= $level ); # ASA - visit_backup_ids $level = $m->{backups}[$i]{level}; $backupNum = $m->{backups}[$i]{num}; @@ -123,6 +142,8 @@ sub dirCache #print(STDERR "Opening $path (share=$share, mangle=$mangle)\n"); my $dirOpts = { %{$m->{dirOpts} || {} } }; + $dirOpts->{inode} = 1 if $m->{dirOpts}->{only_increment}; # ASA - detect unchanged +#warn "# dirOpts = ",dump $dirOpts; my $attribOpts = { compress => $compress }; if ( $legacyCharset ) { $dirOpts->{charsetLegacy} @@ -157,14 +178,34 @@ sub dirCache # # skip special files # - next if ( defined($m->{files}{$fileUM}) + next if ( 0 # defined($m->{files}{$fileUM}) # ASA - need fallthrough || $file eq ".." || $file eq "." || $file eq "backupInfo" || $mangle && $file eq "attrib" ); + + # ASA - we only skip files when invoked with share name + if ( $m->{dirOpts}->{only_increment} && $share ) { + if ( defined $previous_increment_entry->{$fileUM} + && $previous_increment_entry->{$fileUM}->{inode} == $entry->{inode} ) { + #warn "# -- $backupNum $fileUM\n"; + $previous_increment_entry->{$fileUM}->{_hide}++; + next; + } elsif ( $backupNum < $increment_backupNum ) { + #warn "# << $backupNum $fileUM\n"; + next; + } else { + #warn "# ++ $backupNum $fileUM ",dump $entry; + $previous_increment_entry->{$fileUM} = $entry; + } + } else { + next if defined($m->{files}{$fileUM}); + } + if ( defined($attr) && defined(my $a = $attr->get($fileUM)) ) { $m->{files}{$fileUM} = $a; + $previous_increment_entry->{$fileUM}->{_dir}++ if $a->{type} == BPC_FTYPE_DIR; # ASA # # skip directories in earlier backups (each backup always # has the complete directory tree). @@ -223,6 +264,7 @@ sub dirCache $m->{files}{$fileUM}{inode} = $entry->{inode} if ( $m->{dirOpts}{inode} ); } + # # Also include deleted files # @@ -245,6 +287,16 @@ sub dirCache } } } + + # ASA create increment + if ( $m->{dirOpts}->{only_increment} ) { + warn "# previous_increment_entry = ",dump $previous_increment_entry; + foreach my $file ( grep { exists $previous_increment_entry->{$_}->{_hide} && ! exists $previous_increment_entry->{$_}->{_dir} } keys %$previous_increment_entry ) { + delete $m->{files}{$file}; + #warn "OLD $file\n"; + } + } + # # Prune deleted files #