r10297@llin: dpavlin | 2006-03-01 14:40:39 +0100
[BackupPC.git] / bin / BackupPC_recover_meta
index b443f39..147d07e 100755 (executable)
@@ -23,14 +23,19 @@ my $pc_dir = "$TopDir/pc/$host";
 print "working in $pc_dir\n";
 
 sub extract_num($) {
-       my $file = shift || die;
-       my $nr = $1 if ($file =~ m/XferLOG\.(\d+)/);
-       return $nr || die;
+       my $file = shift || die "no file?";
+       my $nr;
+       if ($file =~ m/XferLOG\.(\d+)/) {
+               $nr = $1;
+       } else {
+               die "can't extract number from $file";
+       }
+       return $nr;
 }
 
 my @logs = sort {
        extract_num($a) <=> extract_num($b)
-} glob("$pc_dir/XferLOG*");
+} glob("$pc_dir/XferLOG.[0-9]*");
 
 print "found ", $#logs + 1, " XferLOG files for $host\n";
 
@@ -49,6 +54,8 @@ if (-e $backups_file) {
        print "WARNING: backups file $backups_file doesn't exist, creating new one\n";
 }
 
+my @new_backups;
+
 foreach my $xfer_log (@logs) {
 
        my $num = extract_num($xfer_log);
@@ -69,13 +76,13 @@ foreach my $xfer_log (@logs) {
        my $xfer_fh = BackupPC::FileZIO->open($xfer_log, 0, $Conf{CompressLevel});
        while ( my $line = $xfer_fh->readLine() ) {
                chomp($line);
-               if ($line =~ m#^\s+(create|pool|delete)\s+(.)\s\d\d\d\s+\d+/\d+\s+(\d+)\s(.+)$#) {
+               if ($line =~ m#^\s+(create|pool|delete|same|link)\s+(.)\s\d\d\d\s+\d+/\d+\s+(\d+)\s(.+)$#) {
                        my ($type,$is_dir,$size,$path) = ($1,$2,$3);
                        #print "$type [$is_dir] $size $path\n";
 
                        next if ($is_dir eq 'd');
 
-                       if ($type eq 'pool') {
+                       if ($type eq 'pool' || $type eq 'same') {
                                $sizeExist += $size;
                                $nFilesExist++;
                        } elsif ($type ne 'delete') {
@@ -109,6 +116,7 @@ foreach my $xfer_log (@logs) {
                mangle         => 1,        # name mangling always on for v1.04+
        };
 
-       print Dumper($this_backup);
+       push @new_backups, $this_backup;
+       $bpc->BackupInfoWrite($host, @new_backups);
 }