9 |
use Getopt::Std; |
use Getopt::Std; |
10 |
use constant BPC_FTYPE_DIR => 5; |
use constant BPC_FTYPE_DIR => 5; |
11 |
|
|
12 |
|
my $debug = 0; |
13 |
$|=1; |
$|=1; |
14 |
|
|
15 |
my $hosts; |
my $hosts; |
193 |
my ($broj) = $sth->{backups_broj}->fetchrow_array(); |
my ($broj) = $sth->{backups_broj}->fetchrow_array(); |
194 |
next if ($broj > 0); |
next if ($broj > 0); |
195 |
|
|
|
$sth->{insert_backups}->execute( |
|
|
$hostID, |
|
|
$backupNum, |
|
|
$backup->{'endTime'}, |
|
|
$backup->{'type'} |
|
|
); |
|
|
$dbh->commit(); |
|
|
|
|
196 |
my $files = BackupPC::View->new($bpc, $hostname, \@backups); |
my $files = BackupPC::View->new($bpc, $hostname, \@backups); |
197 |
foreach my $share ($files->shareList($backupNum)) { |
foreach my $share ($files->shareList($backupNum)) { |
198 |
|
|
203 |
print " $nf/$f files $nd/$d dirs\n"; |
print " $nf/$f files $nd/$d dirs\n"; |
204 |
$dbh->commit(); |
$dbh->commit(); |
205 |
} |
} |
206 |
|
|
207 |
|
$sth->{insert_backups}->execute( |
208 |
|
$hostID, |
209 |
|
$backupNum, |
210 |
|
$backup->{'endTime'}, |
211 |
|
$backup->{'type'} |
212 |
|
); |
213 |
|
$dbh->commit(); |
214 |
|
|
215 |
} |
} |
216 |
} |
} |
217 |
undef $sth; |
undef $sth; |
273 |
|
|
274 |
my ($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID) = @_; |
my ($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID) = @_; |
275 |
|
|
276 |
my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0); |
print STDERR "recurse($hostname,$backupNum,$share,$dir,$shareID)\n" if ($debug >= 1); |
277 |
|
|
278 |
my @stack; |
my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0); |
279 |
|
|
280 |
{ # scope |
{ # scope |
281 |
|
my @stack; |
282 |
|
|
283 |
my $files = BackupPC::View->new($bpc, $hostname, $backups); |
my $files = BackupPC::View->new($bpc, $hostname, $backups); |
284 |
my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir); |
my $filesInBackup = $files->dirAttrib($backupNum, $share, $dir); |
285 |
|
|
|
print STDERR "$hostname: $share | $dir | $backupNum\n"; |
|
|
|
|
286 |
# first, add all the entries in current directory |
# first, add all the entries in current directory |
287 |
foreach my $path_key (keys %{$filesInBackup}) { |
foreach my $path_key (keys %{$filesInBackup}) { |
288 |
my @data = ( |
my @data = ( |
307 |
|
|
308 |
|
|
309 |
if (! $beenThere->{$key} && ! found_in_db(@data)) { |
if (! $beenThere->{$key} && ! found_in_db(@data)) { |
310 |
|
print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2); |
311 |
$sth->{'insert_files'}->execute(@data); |
$sth->{'insert_files'}->execute(@data); |
|
print STDERR "$key\n"; |
|
312 |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
313 |
$new_dirs++; |
$new_dirs++; |
314 |
|
print STDERR " dir\n" if ($debug >= 2); |
315 |
} else { |
} else { |
316 |
$new_files++; |
$new_files++; |
317 |
|
print STDERR " file\n" if ($debug >= 2); |
318 |
} |
} |
319 |
} |
} |
320 |
$beenThere->{$key}++; |
$beenThere->{$key}++; |
322 |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
323 |
$nr_dirs++; |
$nr_dirs++; |
324 |
|
|
325 |
push @stack, [ $bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID ] unless ($beenThere->{$key}); |
my $full_path = $dir . '/' . $path_key; |
326 |
|
push @stack, $full_path; |
327 |
|
print STDERR "### store to stack: $full_path\n" if ($debug >= 3); |
328 |
|
|
329 |
# my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID) unless ($beenThere->{$key}); |
# my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID) unless ($beenThere->{$key}); |
330 |
# |
# |
331 |
# $nr_files += $f; |
# $nr_files += $f; |
338 |
} |
} |
339 |
} |
} |
340 |
|
|
341 |
} |
print STDERR "## STACK ",join(", ", @stack),"\n" if ($debug >= 2); |
342 |
|
|
343 |
foreach my $r (@stack) { |
while ( my $dir = shift @stack ) { |
344 |
my ($f,$nf,$d,$nd) = recurseDir(@{$r}); |
my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID); |
345 |
$nr_files += $f; |
print STDERR "# $dir f: $f nf: $nf d: $d nd: $nd\n" if ($debug >= 1); |
346 |
$new_files += $nf; |
$nr_files += $f; |
347 |
$nr_dirs += $d; |
$new_files += $nf; |
348 |
$new_dirs += $nd; |
$nr_dirs += $d; |
349 |
|
$new_dirs += $nd; |
350 |
|
} |
351 |
} |
} |
352 |
|
|
353 |
return ($nr_files, $new_files, $nr_dirs, $new_dirs); |
return ($nr_files, $new_files, $nr_dirs, $new_dirs); |