X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC;h=ba6cde9d2f7b472ebe9c9623558a72a19334f986;hp=3f1fa2b1bbb5b93216087e47460826eab58d8d2f;hb=d6dd48e6594d937dea49e3dd1c5ddaba6719df0d;hpb=a7e968ce327855f2ba2624ca8517069a936c9b5b diff --git a/bin/BackupPC b/bin/BackupPC index 3f1fa2b..ba6cde9 100755 --- a/bin/BackupPC +++ b/bin/BackupPC @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC: Main program for PC backups. @@ -47,7 +47,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.1.0_CVS, released 13 Mar 2004. # # See http://backuppc.sourceforge.net. # @@ -772,7 +772,7 @@ sub Main_Check_Job_Messages if ( defined($Jobs{$newHost}) ) { print(LOG $bpc->timeStamp, "Backup on $newHost is already running\n"); - kill(2, $Jobs{$host}{pid}); + kill($bpc->sigName2num("INT"), $Jobs{$host}{pid}); $nbytes = 0; last; } @@ -818,18 +818,42 @@ sub Main_Check_Job_Messages $Status{$host}{startTime} = time; $Status{$host}{deadCnt} = 0; $Status{$host}{aliveCnt}++; + } elsif ( $mesg =~ /^started_archive/ ) { + $Jobs{$host}{type} = "archive"; + print(LOG $bpc->timeStamp, + "Started archive on $host" + . " (pid=$Jobs{$host}{pid})\n"); + $Status{$host}{state} = "Status_archive_in_progress"; + $Status{$host}{reason} = ""; + $Status{$host}{type} = "archive"; + $Status{$host}{startTime} = time; + $Status{$host}{deadCnt} = 0; + $Status{$host}{aliveCnt}++; } elsif ( $mesg =~ /^(full|incr) backup complete/ ) { print(LOG $bpc->timeStamp, "Finished $1 backup on $host\n"); $Status{$host}{reason} = "Reason_backup_done"; delete($Status{$host}{error}); delete($Status{$host}{errorTime}); $Status{$host}{endTime} = time; + } elsif ( $mesg =~ /^backups disabled/ ) { + print(LOG $bpc->timeStamp, + "Ignoring old backup error on $host\n"); + $Status{$host}{reason} = "Reason_backup_done"; + delete($Status{$host}{error}); + delete($Status{$host}{errorTime}); + $Status{$host}{endTime} = time; } elsif ( $mesg =~ /^restore complete/ ) { print(LOG $bpc->timeStamp, "Finished restore on $host\n"); $Status{$host}{reason} = "Reason_restore_done"; delete($Status{$host}{error}); delete($Status{$host}{errorTime}); $Status{$host}{endTime} = time; + } elsif ( $mesg =~ /^archive complete/ ) { + print(LOG $bpc->timeStamp, "Finished archive on $host\n"); + $Status{$host}{reason} = "Reason_archive_done"; + delete($Status{$host}{error}); + delete($Status{$host}{errorTime}); + $Status{$host}{endTime} = time; } elsif ( $mesg =~ /^nothing to do/ ) { if ( $Status{$host}{reason} ne "Reason_backup_failed" && $Status{$host}{reason} ne "Reason_restore_failed" ) { @@ -856,18 +880,46 @@ sub Main_Check_Job_Messages } } elsif ( $mesg =~ /^dump failed: (.*)/ ) { $Status{$host}{state} = "Status_idle"; - $Status{$host}{reason} = "Reason_backup_failed"; + $Status{$host}{error} = $1; + $Status{$host}{errorTime} = time; + $Status{$host}{endTime} = time; + if ( $Status{$host}{reason} + eq "Reason_backup_canceled_by_user" ) { + print(LOG $bpc->timeStamp, + "Backup canceled on $host ($1)\n"); + } else { + $Status{$host}{reason} = "Reason_backup_failed"; + print(LOG $bpc->timeStamp, + "Backup failed on $host ($1)\n"); + } + } elsif ( $mesg =~ /^restore failed: (.*)/ ) { + $Status{$host}{state} = "Status_idle"; $Status{$host}{error} = $1; $Status{$host}{errorTime} = time; $Status{$host}{endTime} = time; - print(LOG $bpc->timeStamp, "Backup failed on $host ($1)\n"); - } elsif ( $mesg =~ /^restore failed: (.*)/ ) { + if ( $Status{$host}{reason} + eq "Reason_restore_canceled_by_user" ) { + print(LOG $bpc->timeStamp, + "Restore canceled on $host ($1)\n"); + } else { + $Status{$host}{reason} = "Reason_restore_failed"; + print(LOG $bpc->timeStamp, + "Restore failed on $host ($1)\n"); + } + } elsif ( $mesg =~ /^archive failed: (.*)/ ) { $Status{$host}{state} = "Status_idle"; - $Status{$host}{reason} = "Reason_restore_failed"; $Status{$host}{error} = $1; $Status{$host}{errorTime} = time; $Status{$host}{endTime} = time; - print(LOG $bpc->timeStamp, "Restore failed on $host ($1)\n"); + if ( $Status{$host}{reason} + eq "Reason_archive_canceled_by_user" ) { + print(LOG $bpc->timeStamp, + "Archive canceled on $host ($1)\n"); + } else { + $Status{$host}{reason} = "Reason_archive_failed"; + print(LOG $bpc->timeStamp, + "Archive failed on $host ($1)\n"); + } } elsif ( $mesg =~ /^log\s+(.*)/ ) { print(LOG $bpc->timeStamp, "$1\n"); } elsif ( $mesg =~ /^BackupPC_stats = (.*)/ ) { @@ -1019,7 +1071,7 @@ sub Main_Check_Client_Messages print(LOG $bpc->timeStamp, "Stopping current $Jobs{$host}{type} of $host," . " request by $user (backoff=$backoff)\n"); - kill(2, $Jobs{$host}{pid}); + kill($bpc->sigName2num("INT"), $Jobs{$host}{pid}); # # Don't close the pipe now; wait until the child # really exits later. Otherwise close() will @@ -1042,7 +1094,7 @@ sub Main_Check_Client_Messages } $Status{$host}{activeJob} = 0; $Status{$host}{startTime} = time; - $reply = "ok: $Jobs{$host}{type} of $host cancelled"; + $reply = "ok: $Jobs{$host}{type} of $host canceled"; } elsif ( $BgQueueOn{$host} || $UserQueueOn{$host} ) { print(LOG $bpc->timeStamp, "Stopping pending backup of $host," @@ -1050,7 +1102,7 @@ sub Main_Check_Client_Messages @BgQueue = grep($_->{host} ne $host, @BgQueue); @UserQueue = grep($_->{host} ne $host, @UserQueue); $BgQueueOn{$host} = $UserQueueOn{$host} = 0; - $reply = "ok: pending backup of $host cancelled"; + $reply = "ok: pending backup of $host canceled"; } else { print(LOG $bpc->timeStamp, "Nothing to do for stop backup of $host," @@ -1225,7 +1277,7 @@ sub Main_Check_Client_Messages } elsif ( $cmd =~ /^server\s+(\w+)/ ) { my($type) = $1; if ( $type eq 'reload' ) { - ServerReload("Reloading server configuration..."); + ServerReload("Reloading config/host files via CGI request"); } elsif ( $type eq 'shutdown' ) { $reply = "Shutting down...\n"; syswrite($Clients{$client}{fh}, $reply, length($reply)); @@ -1460,7 +1512,7 @@ sub catch_signal if ( $SigName ) { $SigName = shift; foreach my $host ( keys(%Jobs) ) { - kill(2, $Jobs{$host}{pid}); + kill($bpc->sigName2num("INT"), $Jobs{$host}{pid}); } # # In case we are inside the exit handler, reopen the log file @@ -1580,11 +1632,11 @@ sub ServerShutdown print(LOG $bpc->timeStamp, "$mesg\n"); if ( keys(%Jobs) ) { foreach my $host ( keys(%Jobs) ) { - kill(2, $Jobs{$host}{pid}); + kill($bpc->sigName2num("INT"), $Jobs{$host}{pid}); } sleep(1); foreach my $host ( keys(%Jobs) ) { - kill(9, $Jobs{$host}{pid}); + kill($bpc->sigName2num("KILL"), $Jobs{$host}{pid}); } %Jobs = (); }