#
#========================================================================
#
-# Version 2.1.0_CVS, released 3 Jul 2003.
+# Version 3.0.0alpha, released 23 Jan 2006.
#
# See http://backuppc.sourceforge.net.
#
}, $class;
for ( my $i = 0 ; $i < @{$m->{backups}} ; $i++ ) {
next if ( defined($m->{backups}[$i]{level}) );
- $m->{backups}[$i]{level} = $m->{backups}[$i]{type} eq "full" ? 0 : 1;
+ $m->{backups}[$i]{level} = $m->{backups}[$i]{type} eq "incr" ? 1 : 0;
}
$m->{topDir} = $m->{bpc}->TopDir();
return $m;
$dir =~ s{/+$}{};
return if ( $m->{num} == $backupNum
&& $m->{share} eq $share
+ && defined($m->{dir})
&& $m->{dir} eq $dir );
- if ( $m->{num} != $backupNum ) {
- for ( $i = 0 ; $i < @{$m->{backups}} ; $i++ ) {
- last if ( $m->{backups}[$i]{num} == $backupNum );
- }
- if ( $i >= @{$m->{backups}} ) {
- $m->{idx} = -1;
- return;
- }
- $m->{num} = $backupNum;
- $m->{idx} = $i;
- }
+ $m->backupNumCache($backupNum) if ( $m->{num} != $backupNum );
+ return if ( $m->{idx} < 0 );
+
$m->{files} = {};
$level = $m->{backups}[$m->{idx}]{level} + 1;
next if ( defined($m->{files}{$fileUM})
|| $file eq ".."
|| $file eq "."
+ || $file eq "backupInfo"
|| $mangle && $file eq "attrib" );
#
# skip directories in earlier backups (each backup always
}
}
}
- $m->{files}{$fileUM}{relPath} = "$dir/$fileUM";
- $m->{files}{$fileUM}{sharePathM} = "$sharePathM/$file";
- $m->{files}{$fileUM}{fullPath} = "$path/$file";
- $m->{files}{$fileUM}{backupNum} = $backupNum;
- $m->{files}{$fileUM}{compress} = $compress;
- $m->{files}{$fileUM}{nlink} = $s[3];
- $m->{files}{$fileUM}{inode} = $s[1];
+ ($m->{files}{$fileUM}{relPath} = "$dir/$fileUM") =~ s{//+}{/}g;
+ ($m->{files}{$fileUM}{sharePathM} = "$sharePathM/$file")
+ =~ s{//+}{/}g;
+ ($m->{files}{$fileUM}{fullPath} = "$path/$file") =~ s{//+}{/}g;
+ $m->{files}{$fileUM}{backupNum} = $backupNum;
+ $m->{files}{$fileUM}{compress} = $compress;
+ $m->{files}{$fileUM}{nlink} = $s[3];
+ $m->{files}{$fileUM}{inode} = $s[1];
}
#
# Also include deleted files
#print STDERR "Returning:\n", Dumper($m->{files});
}
+#
+# Return list of shares for this backup
+#
+sub shareList
+{
+ my($m, $backupNum) = @_;
+ my @shareList;
+
+ $m->backupNumCache($backupNum) if ( $m->{num} != $backupNum );
+ return if ( $m->{idx} < 0 );
+
+ my $mangle = $m->{backups}[$m->{idx}]{mangle};
+ my $path = "$m->{topDir}/pc/$m->{host}/$backupNum/";
+ return if ( !opendir(DIR, $path) );
+ my @dir = readdir(DIR);
+ closedir(DIR);
+ foreach my $file ( @dir ) {
+ $file = $1 if ( $file =~ /(.*)/ );
+ next if ( $file eq "attrib" && $mangle
+ || $file eq "."
+ || $file eq ".." );
+ my $fileUM = $file;
+ $fileUM = $m->{bpc}->fileNameUnmangle($fileUM) if ( $mangle );
+ push(@shareList, $fileUM);
+ }
+ $m->{dir} = undef;
+ return @shareList;
+}
+
+sub backupNumCache
+{
+ my($m, $backupNum) = @_;
+
+ if ( $m->{num} != $backupNum ) {
+ my $i;
+ for ( $i = 0 ; $i < @{$m->{backups}} ; $i++ ) {
+ last if ( $m->{backups}[$i]{num} == $backupNum );
+ }
+ if ( $i >= @{$m->{backups}} ) {
+ $m->{idx} = -1;
+ return;
+ }
+ $m->{num} = $backupNum;
+ $m->{idx} = $i;
+ }
+}
+
#
# Return the attributes of a specific file
#
{
my($m, $backupNum, $share, $path) = @_;
+ #print(STDERR "fileAttrib($backupNum, $share, $path)\n");
if ( $path =~ s{(.*)/+(.+)}{$1} ) {
my $file = $2;
$m->dirCache($backupNum, $share, $path);
} else {
#print STDERR "Got empty $path\n";
$m->dirCache($backupNum, "", "");
- my %attr = %{$m->{files}{$share}};
- $attr{relPath} = "/";
- return \%attr;
+ my $attr = $m->{files}{$share};
+ return if ( !defined($attr) );
+ $attr->{relPath} = "/";
+ return $attr;
}
}
return $m->{files};
}
+#
+# Return a listref of backup numbers that are merged to create this view
+#
sub mergeNums
{
my($m) = @_;
return $m->{mergeNums};
}
+#
+# Return a list of backup indexes for which the directory exists
+#
sub backupList
{
my($m, $share, $dir) = @_;
}
$path .= $sharePathM;
next if ( !-d $path );
- push(@backupList, $backupNum);
+ push(@backupList, $i);
}
return @backupList;
}
}
}
}
- $files->{$fileUM}[$i]{relPath} = "$dir/$fileUM";
- $files->{$fileUM}[$i]{sharePathM} = "$sharePathM/$file";
- $files->{$fileUM}[$i]{fullPath} = "$path/$file";
- $files->{$fileUM}[$i]{backupNum} = $backupNum;
- $files->{$fileUM}[$i]{compress} = $compress;
- $files->{$fileUM}[$i]{nlink} = $s[3];
- $files->{$fileUM}[$i]{inode} = $s[1];
+ ($files->{$fileUM}[$i]{relPath} = "$dir/$fileUM") =~ s{//+}{/}g;
+ ($files->{$fileUM}[$i]{sharePathM} = "$sharePathM/$file")
+ =~ s{//+}{/}g;
+ ($files->{$fileUM}[$i]{fullPath} = "$path/$file") =~ s{//+}{/}g;
+ $files->{$fileUM}[$i]{backupNum} = $backupNum;
+ $files->{$fileUM}[$i]{compress} = $compress;
+ $files->{$fileUM}[$i]{nlink} = $s[3];
+ $files->{$fileUM}[$i]{inode} = $s[1];
}
#
my $a = $attr->get;
foreach my $fileUM ( keys(%$a) ) {
next if ( $a->{$fileUM}{type} != BPC_FTYPE_DELETED );
- $files->{$fileUM}[$i] = undef;
+ $files->{$fileUM}[$i] = undef if ( defined($files->{$fileUM}) );
}
}
}
{
my($m, $backupNum, $share, $path, $depth, $callback, @callbackArgs) = @_;
+ #print(STDERR "find: got $backupNum, $share, $path\n");
#
# First call the callback on the given $path
#