-#!/bin/perl -T
+#!/bin/perl
#============================================================= -*-perl-*-
#
# BackupPC_dump: Dump a single client.
#
#========================================================================
#
-# Version 2.1.0_CVS, released 3 Jul 2003.
+# Version 2.1.0_CVS, released 8 Feb 2004.
#
# See http://backuppc.sourceforge.net.
#
#
$hostIP = $client;
if ( $bpc->CheckHostAlive($hostIP) < 0 ) {
- print("Exiting because CheckHostAlive($hostIP) failed\n")
+ print(STDERR "Exiting because CheckHostAlive($hostIP) failed\n")
if ( $opts{v} );
exit(1);
}
if ( $Conf{NmbLookupCmd} eq "" ) {
- print("Exiting because \$Conf{NmbLookupCmd} is empty\n")
+ print(STDERR "Exiting because \$Conf{NmbLookupCmd} is empty\n")
if ( $opts{v} );
exit(1);
}
($client, $user) = $bpc->NetBiosInfoGet($hostIP);
if ( $client !~ /^([\w\.\s-]+)$/ ) {
- print("Exiting because NetBiosInfoGet($hostIP) returned '$client',"
- . " an invalid host name\n")
- if ( $opts{v} );
+ print(STDERR "Exiting because NetBiosInfoGet($hostIP) returned"
+ . " '$client', an invalid host name\n") if ( $opts{v} );
exit(1)
}
$Hosts = $bpc->HostInfoRead($client);
$Hosts = $bpc->HostInfoRead($client);
}
if ( !defined($Hosts->{$client}) ) {
- print("Exiting because host $client does not exist in the hosts file\n")
- if ( $opts{v} );
+ print(STDERR "Exiting because host $client does not exist in the"
+ . " hosts file\n") if ( $opts{v} );
exit(1)
}
exit(0);
}
+#
+# For archive hosts we don't bother any further
+#
+if ($Conf{XferMethod} eq "archive" ) {
+ exit(0);
+}
+
if ( !$opts{d} ) {
#
# In the non-DHCP case, make sure the host can be looked up
# Ok, NS doesn't know about it. Maybe it is a NetBios name
# instead.
#
- print("Name server doesn't know about $host; trying NetBios\n")
+ print(STDERR "Name server doesn't know about $host; trying NetBios\n")
if ( $opts{v} );
if ( !defined($hostIP = $bpc->NetBiosHostIPFind($host)) ) {
print(LOG $bpc->timeStamp, "Can't find host $host via netbios\n");
if ( $opts{d} ) {
if ( $StatusHost{activeJob} ) {
# oops, something is already running for this host
- print("Exiting because backup is already running for $client\n")
+ print(STDERR "Exiting because backup is already running for $client\n")
if ( $opts{v} );
exit(0);
}
my $lastFull = 0;
my $lastIncr = 0;
my $partialIdx = -1;
+my $partialNum;
if ( $Conf{FullPeriod} == -1 && !$opts{f} && !$opts{i}
|| $Conf{FullPeriod} == -2 ) {
&& $StatusHost{aliveCnt} >= $Conf{BlackoutGoodCnt} ) {
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my($currHours) = $hour + $min / 60 + $sec / 3600;
- if ( $Conf{BlackoutHourBegin} <= $currHours
- && $currHours <= $Conf{BlackoutHourEnd}
- && grep($_ == $wday, @{$Conf{BlackoutWeekDays}}) ) {
+ my $blackout;
+ #
+ # Allow blackout to span midnight (specified by BlackoutHourBegin
+ # being greater than BlackoutHourEnd)
+ #
+ if ( $Conf{BlackoutHourBegin} > $Conf{BlackoutHourEnd} ) {
+ $blackout = $Conf{BlackoutHourBegin} <= $currHours
+ || $currHours <= $Conf{BlackoutHourEnd};
+ if ( $currHours <= $Conf{BlackoutHourEnd} ) {
+ #
+ # This is after midnight, so decrement the weekday for the
+ # weekday check (eg: Monday 11pm-1am means Monday 2300 to
+ # Tuesday 0100, not Monday 2300-2400 plus Monday 0000-0100).
+ #
+ $wday--;
+ $wday += 7 if ( $wday < 0 );
+ }
+ } else {
+ $blackout = $Conf{BlackoutHourBegin} <= $currHours
+ && $currHours <= $Conf{BlackoutHourEnd};
+ }
+ if ( $blackout && grep($_ == $wday, @{$Conf{BlackoutWeekDays}}) ) {
# print(LOG $bpc->timeStamp, "skipping because of blackout"
# . " (alive $StatusHost{aliveCnt} times)\n");
+ print(STDERR "Skipping $client because of blackout\n")
+ if ( $opts{v} );
NothingToDo($needLink);
}
}
if ( $lastIncr < $Backups[$i]{startTime} );
} elsif ( $Backups[$i]{type} eq "partial" ) {
$partialIdx = $i;
+ $partialNum = $Backups[$i]{num};
}
}
print("dump failed: unable to open/create $Dir/XferLOG$fileExt\n");
exit(1);
}
-$XferLOG->writeTeeStdout(1) if ( $opts{v} );
+$XferLOG->writeTeeStderr(1) if ( $opts{v} );
unlink("$Dir/NewFileList");
my $startTime = time();
open(STDERR, ">&STDOUT");
close(STDIN);
open(STDIN, "<&RH");
+ alarm(0);
exec("$BinDir/BackupPC_tarExtract", $client, $shareName,
$Conf{CompressLevel});
print(LOG $bpc->timeStamp,
compress => $Conf{CompressLevel},
XferMethod => $Conf{XferMethod},
pidHandler => \&pidHandler,
+ partialNum => $partialNum,
});
if ( !defined($logMsg = $xfer->start()) ) {
}
#
-# If any share had zero files then consider the dump bad
+# If this is a full, and any share had zero files then consider the dump bad
#
-if ( $stat{hostError} eq ""
- && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) {
+if ( $type eq "full" && $stat{hostError} eq ""
+ && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) {
$stat{hostError} = $noFilesErr;
$stat{xferOK} = 0;
}