/[BackupPC]/trunk/bin/BackupPC_recover_meta
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_recover_meta

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 232 by dpavlin, Fri Nov 4 15:10:26 2005 UTC revision 233 by dpavlin, Fri Nov 4 15:40:51 2005 UTC
# Line 23  my $pc_dir = "$TopDir/pc/$host"; Line 23  my $pc_dir = "$TopDir/pc/$host";
23  print "working in $pc_dir\n";  print "working in $pc_dir\n";
24    
25  sub extract_num($) {  sub extract_num($) {
26          my $file = shift || die;          my $file = shift || die "no file?";
27          my $nr = $1 if ($file =~ m/XferLOG\.(\d+)/);          my $nr;
28          return $nr || die;          if ($file =~ m/XferLOG\.(\d+)/) {
29                    $nr = $1;
30            } else {
31                    die "can't extract number from $file";
32            }
33            return $nr;
34  }  }
35    
36  my @logs = sort {  my @logs = sort {
37          extract_num($a) <=> extract_num($b)          extract_num($a) <=> extract_num($b)
38  } glob("$pc_dir/XferLOG*");  } glob("$pc_dir/XferLOG.[0-9]*");
39    
40  print "found ", $#logs + 1, " XferLOG files for $host\n";  print "found ", $#logs + 1, " XferLOG files for $host\n";
41    
# Line 49  if (-e $backups_file) { Line 54  if (-e $backups_file) {
54          print "WARNING: backups file $backups_file doesn't exist, creating new one\n";          print "WARNING: backups file $backups_file doesn't exist, creating new one\n";
55  }  }
56    
57    my @new_backups;
58    
59  foreach my $xfer_log (@logs) {  foreach my $xfer_log (@logs) {
60    
61          my $num = extract_num($xfer_log);          my $num = extract_num($xfer_log);
# Line 69  foreach my $xfer_log (@logs) { Line 76  foreach my $xfer_log (@logs) {
76          my $xfer_fh = BackupPC::FileZIO->open($xfer_log, 0, $Conf{CompressLevel});          my $xfer_fh = BackupPC::FileZIO->open($xfer_log, 0, $Conf{CompressLevel});
77          while ( my $line = $xfer_fh->readLine() ) {          while ( my $line = $xfer_fh->readLine() ) {
78                  chomp($line);                  chomp($line);
79                  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(.+)$#) {
80                          my ($type,$is_dir,$size,$path) = ($1,$2,$3);                          my ($type,$is_dir,$size,$path) = ($1,$2,$3);
81                          #print "$type [$is_dir] $size $path\n";                          #print "$type [$is_dir] $size $path\n";
82    
83                          next if ($is_dir eq 'd');                          next if ($is_dir eq 'd');
84    
85                          if ($type eq 'pool') {                          if ($type eq 'pool' || $type eq 'same') {
86                                  $sizeExist += $size;                                  $sizeExist += $size;
87                                  $nFilesExist++;                                  $nFilesExist++;
88                          } elsif ($type ne 'delete') {                          } elsif ($type ne 'delete') {
# Line 109  foreach my $xfer_log (@logs) { Line 116  foreach my $xfer_log (@logs) {
116                  mangle         => 1,        # name mangling always on for v1.04+                  mangle         => 1,        # name mangling always on for v1.04+
117          };          };
118    
119          print Dumper($this_backup);          push @new_backups, $this_backup;
120            $bpc->BackupInfoWrite($host, @new_backups);
121  }  }
122    

Legend:
Removed from v.232  
changed lines
  Added in v.233

  ViewVC Help
Powered by ViewVC 1.1.26