/[BackupPC]/trunk/bin/BackupPC
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

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

revision 2 by dpavlin, Wed Jun 22 19:12:42 2005 UTC revision 316 by dpavlin, Mon Jan 30 13:37:17 2006 UTC
# Line 47  Line 47 
47  #  #
48  #========================================================================  #========================================================================
49  #  #
50  # Version 2.1.0, released 20 Jun 2004.  # Version 2.1.2, released 5 Sep 2005.
51  #  #
52  # See http://backuppc.sourceforge.net.  # See http://backuppc.sourceforge.net.
53  #  #
# Line 66  use Getopt::Std; Line 66  use Getopt::Std;
66  use Socket;  use Socket;
67  use Carp;  use Carp;
68  use Digest::MD5;  use Digest::MD5;
69    use POSIX qw(setsid);
70    
71  ###########################################################################  ###########################################################################
72  # Handle command line options  # Handle command line options
# Line 260  sub Main_Initialize Line 261  sub Main_Initialize
261    
262      if ( $opts{d} ) {      if ( $opts{d} ) {
263          #          #
264          # daemonize by forking          # daemonize by forking; more robust method per:
265            #       http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=301057
266          #          #
267          defined(my $pid = fork) or die "Can't fork: $!";          my $pid;
268            defined($pid = fork) or die("Can't fork: $!");
269            exit if( $pid );   # parent exits
270    
271            POSIX::setsid();
272            defined($pid = fork) or die("Can't fork: $!");
273          exit if $pid;   # parent exits          exit if $pid;   # parent exits
274    
275            chdir ("/") or die("Cannot chdir to /: $!\n");
276            close(STDIN);
277            open(STDIN , ">/dev/null") or die("Cannot open /dev/null as stdin\n");
278            # STDOUT and STDERR are handled in LogFileOpen() right below,
279            # otherwise we would have to reopen them too.
280      }      }
281    
282      #      #
# Line 922  sub Main_Check_Job_Messages Line 935  sub Main_Check_Job_Messages
935                  delete($Status{$host}{error});                  delete($Status{$host}{error});
936                  delete($Status{$host}{errorTime});                  delete($Status{$host}{errorTime});
937                  $Status{$host}{endTime}   = time;                  $Status{$host}{endTime}   = time;
938                    $Status{$host}{lastGoodBackupTime} = time;
939              } elsif ( $mesg =~ /^backups disabled/ ) {              } elsif ( $mesg =~ /^backups disabled/ ) {
940                  print(LOG $bpc->timeStamp,                  print(LOG $bpc->timeStamp,
941                              "Ignoring old backup error on $host\n");                              "Ignoring old backup error on $host\n");
# Line 1540  sub StatusWrite Line 1554  sub StatusWrite
1554  #  #
1555  sub HostSortCompare  sub HostSortCompare
1556  {  {
1557        #
1558        # Hosts with errors go before hosts without errors
1559        #
1560      return -1 if ( $Status{$a}{error} ne "" && $Status{$b}{error} eq "" );      return -1 if ( $Status{$a}{error} ne "" && $Status{$b}{error} eq "" );
1561    
1562        #
1563        # Hosts with no errors go after hosts with errors
1564        #
1565    
1566      return  1 if ( $Status{$a}{error} eq "" && $Status{$b}{error} ne "" );      return  1 if ( $Status{$a}{error} eq "" && $Status{$b}{error} ne "" );
1567      return $Status{$a}{endTime} <=> $Status{$b}{endTime};  
1568        #
1569        # hosts with the older last good backups sort earlier
1570        #
1571        my $r = $Status{$a}{lastGoodBackupTime} <=> $Status{$b}{lastGoodBackupTime};
1572        return $r if ( $r );
1573    
1574        #
1575        # Finally, just sort based on host name
1576        #
1577        return $a cmp $b;
1578  }  }
1579    
1580    
1581  #  #
1582  # Queue all the hosts for backup.  This means queuing all the fixed  # Queue all the hosts for backup.  This means queuing all the fixed
1583  # ip hosts and all the dhcp address ranges.  We also additionally  # ip hosts and all the dhcp address ranges.  We also additionally
# Line 1806  sub ServerShutdown Line 1839  sub ServerShutdown
1839          }          }
1840          %Jobs = ();          %Jobs = ();
1841      }      }
1842        delete($Info{pid});
1843      StatusWrite();      StatusWrite();
1844      unlink("$TopDir/log/BackupPC.pid");      unlink("$TopDir/log/BackupPC.pid");
1845      exit(1);      exit(1);

Legend:
Removed from v.2  
changed lines
  Added in v.316

  ViewVC Help
Powered by ViewVC 1.1.26