--- trunk/bin/BackupPC_updatedb 2005/12/09 16:27:49 249 +++ trunk/bin/BackupPC_updatedb 2005/12/11 14:27:45 250 @@ -12,6 +12,7 @@ use File::Pid; use POSIX qw/strftime/; use BackupPC::SearchLib; +use Cwd qw/abs_path/; use constant BPC_FTYPE_DIR => 5; use constant EST_CHUNK => 100000; @@ -24,7 +25,12 @@ my $start_t = time(); -my $pidfile = new File::Pid; +my $pid_path = abs_path($0); +$pid_path =~ s/\W+/_/g; + +my $pidfile = new File::Pid({ + file => "/tmp/$pid_path", +}); if (my $pid = $pidfile->running ) { die "$0 already running: $pid\n"; @@ -32,8 +38,8 @@ $pidfile->remove; $pidfile = new File::Pid; } -$pidfile->write; print STDERR "$0 using pid ",$pidfile->pid," file ",$pidfile->file,"\n"; +$pidfile->write; my $t_fmt = '%Y-%m-%d %H:%M:%S'; @@ -533,17 +539,22 @@ my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); - $sth->{update_backups_size}->execute( - $size, - $hostID, - $backupNum, - $backup->{'endTime'}, - substr($backup->{'type'},0,4), - $shareID, - ); - - print " commit"; - $dbh->commit(); + eval { + $sth->{update_backups_size}->execute( + $size, + $hostID, + $backupNum, + $backup->{'endTime'}, + substr($backup->{'type'},0,4), + $shareID, + ); + print " commit"; + $dbh->commit(); + }; + if ($@) { + print " rollback"; + $dbh->rollback(); + } my $dur = (time() - $t) || 1; printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n",