96 |
date integer NOT NULL, |
date integer NOT NULL, |
97 |
type CHAR(4) not null, |
type CHAR(4) not null, |
98 |
shareID integer not null references shares(id), |
shareID integer not null references shares(id), |
99 |
|
size integer not null, |
100 |
PRIMARY KEY(hostID, num, shareID) |
PRIMARY KEY(hostID, num, shareID) |
101 |
); |
); |
102 |
}); |
}); |
189 |
}); |
}); |
190 |
|
|
191 |
$sth->{insert_backups} = $dbh->prepare(qq{ |
$sth->{insert_backups} = $dbh->prepare(qq{ |
192 |
INSERT INTO backups (hostID, num, date, type, shareid) |
INSERT INTO backups (hostID, num, date, type, shareid, size) |
193 |
VALUES (?,?,?,?,?) |
VALUES (?,?,?,?,?,?) |
194 |
}); |
}); |
195 |
|
|
196 |
$sth->{insert_files} = $dbh->prepare(qq{ |
$sth->{insert_files} = $dbh->prepare(qq{ |
263 |
# dump some log |
# dump some log |
264 |
print strftime($t_fmt,localtime())," ", $share; |
print strftime($t_fmt,localtime())," ", $share; |
265 |
|
|
266 |
my ($f, $nf, $d, $nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
267 |
|
|
268 |
$sth->{insert_backups}->execute( |
$sth->{insert_backups}->execute( |
269 |
$hostID, |
$hostID, |
270 |
$backupNum, |
$backupNum, |
271 |
$backup->{'endTime'}, |
$backup->{'endTime'}, |
272 |
$backup->{'type'}, |
$backup->{'type'}, |
273 |
$shareID |
$shareID, |
274 |
|
$size, |
275 |
); |
); |
276 |
|
|
277 |
print " commit"; |
print " commit"; |
278 |
$dbh->commit(); |
$dbh->commit(); |
279 |
|
|
280 |
my $dur = (time() - $t) || 1; |
my $dur = (time() - $t) || 1; |
281 |
printf(" %d/%d files %d/%d dirs [%.2f/s dur: %s]\n", |
printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n", |
282 |
$nf, $f, $nd, $d, |
$nf, $f, $nd, $d, |
283 |
|
($size / 1024 / 1024), |
284 |
( ($f+$d) / $dur ), |
( ($f+$d) / $dur ), |
285 |
fmt_time($dur) |
fmt_time($dur) |
286 |
); |
); |
362 |
|
|
363 |
print STDERR "\nrecurse($hostname,$backupNum,$share,$dir,$shareID)\n" if ($debug >= 1); |
print STDERR "\nrecurse($hostname,$backupNum,$share,$dir,$shareID)\n" if ($debug >= 1); |
364 |
|
|
365 |
my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0); |
my ($nr_files, $new_files, $nr_dirs, $new_dirs, $size) = (0,0,0,0,0); |
366 |
|
|
367 |
{ # scope |
{ # scope |
368 |
my @stack; |
my @stack; |
372 |
|
|
373 |
# first, add all the entries in current directory |
# first, add all the entries in current directory |
374 |
foreach my $path_key (keys %{$filesInBackup}) { |
foreach my $path_key (keys %{$filesInBackup}) { |
375 |
|
print STDERR "# file ",Dumper($filesInBackup->{$path_key}),"\n" if ($debug >= 3); |
376 |
my @data = ( |
my @data = ( |
377 |
$shareID, |
$shareID, |
378 |
$backupNum, |
$backupNum, |
402 |
$new_files++; |
$new_files++; |
403 |
print STDERR " file\n" if ($debug >= 2); |
print STDERR " file\n" if ($debug >= 2); |
404 |
} |
} |
405 |
|
$size += $filesInBackup->{$path_key}->{'size'} || 0; |
406 |
} |
} |
407 |
|
|
408 |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
427 |
print STDERR "## STACK ",join(", ", @stack),"\n" if ($debug >= 2); |
print STDERR "## STACK ",join(", ", @stack),"\n" if ($debug >= 2); |
428 |
|
|
429 |
while ( my $dir = shift @stack ) { |
while ( my $dir = shift @stack ) { |
430 |
my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, $dir, $shareID); |
my ($f,$nf,$d,$nd, $s) = recurseDir($bpc, $hostname, $files, $backupNum, $share, $dir, $shareID); |
431 |
print STDERR "# $dir f: $f nf: $nf d: $d nd: $nd\n" if ($debug >= 1); |
print STDERR "# $dir f: $f nf: $nf d: $d nd: $nd\n" if ($debug >= 1); |
432 |
$nr_files += $f; |
$nr_files += $f; |
433 |
$new_files += $nf; |
$new_files += $nf; |
434 |
$nr_dirs += $d; |
$nr_dirs += $d; |
435 |
$new_dirs += $nd; |
$new_dirs += $nd; |
436 |
|
$size += $s; |
437 |
} |
} |
438 |
} |
} |
439 |
|
|
440 |
return ($nr_files, $new_files, $nr_dirs, $new_dirs); |
return ($nr_files, $new_files, $nr_dirs, $new_dirs, $size); |
441 |
} |
} |
442 |
|
|