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 |
|
|
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); |
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') { |
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 |
|
|