/[BackupPC]/trunk/bin/BackupPC_updatedb
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_updatedb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 249 by dpavlin, Fri Dec 9 16:27:49 2005 UTC revision 250 by dpavlin, Sun Dec 11 14:27:45 2005 UTC
# Line 12  use Time::HiRes qw/time/; Line 12  use Time::HiRes qw/time/;
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;
# Line 24  $|=1; Line 25  $|=1;
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";
# Line 32  if (my $pid = $pidfile->running ) { Line 38  if (my $pid = $pidfile->running ) {
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    
# Line 533  foreach my $host_key (@hosts) { Line 539  foreach my $host_key (@hosts) {
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",

Legend:
Removed from v.249  
changed lines
  Added in v.250

  ViewVC Help
Powered by ViewVC 1.1.26