12 |
use File::Pid; |
use File::Pid; |
13 |
use POSIX qw/strftime/; |
use POSIX qw/strftime/; |
14 |
use BackupPC::SearchLib; |
use BackupPC::SearchLib; |
15 |
|
use Cwd qw/abs_path/; |
16 |
|
|
17 |
use constant BPC_FTYPE_DIR => 5; |
use constant BPC_FTYPE_DIR => 5; |
18 |
use constant EST_CHUNK => 100000; |
use constant EST_CHUNK => 100000; |
25 |
|
|
26 |
my $start_t = time(); |
my $start_t = time(); |
27 |
|
|
28 |
my $pidfile = new File::Pid; |
my $pid_path = abs_path($0); |
29 |
|
$pid_path =~ s/\W+/_/g; |
30 |
|
|
31 |
|
my $pidfile = new File::Pid({ |
32 |
|
file => "/tmp/$pid_path", |
33 |
|
}); |
34 |
|
|
35 |
if (my $pid = $pidfile->running ) { |
if (my $pid = $pidfile->running ) { |
36 |
die "$0 already running: $pid\n"; |
die "$0 already running: $pid\n"; |
38 |
$pidfile->remove; |
$pidfile->remove; |
39 |
$pidfile = new File::Pid; |
$pidfile = new File::Pid; |
40 |
} |
} |
|
$pidfile->write; |
|
41 |
print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n"; |
print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n"; |
42 |
|
$pidfile->write; |
43 |
|
|
44 |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
45 |
|
|
539 |
|
|
540 |
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
541 |
|
|
542 |
$sth->{update_backups_size}->execute( |
eval { |
543 |
$size, |
$sth->{update_backups_size}->execute( |
544 |
$hostID, |
$size, |
545 |
$backupNum, |
$hostID, |
546 |
$backup->{'endTime'}, |
$backupNum, |
547 |
substr($backup->{'type'},0,4), |
$backup->{'endTime'}, |
548 |
$shareID, |
substr($backup->{'type'},0,4), |
549 |
); |
$shareID, |
550 |
|
); |
551 |
print " commit"; |
print " commit"; |
552 |
$dbh->commit(); |
$dbh->commit(); |
553 |
|
}; |
554 |
|
if ($@) { |
555 |
|
print " rollback"; |
556 |
|
$dbh->rollback(); |
557 |
|
} |
558 |
|
|
559 |
my $dur = (time() - $t) || 1; |
my $dur = (time() - $t) || 1; |
560 |
printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n", |
printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n", |