-#!/bin/perl -T
+#!/bin/perl
#============================================================= -*-perl-*-
#
# BackupPC_dump: Dump a single client.
#
#========================================================================
#
-# Version 2.0.0, released 14 Jun 2003.
+# Version 2.0.2, released 6 Oct 2003.
#
# See http://backuppc.sourceforge.net.
#
use strict;
no utf8;
-use lib "/usr/local/BackupPC/lib";
+use lib "/usr/local/BackupPC2.0.2/lib";
use BackupPC::Lib;
use BackupPC::FileZIO;
use BackupPC::Xfer::Smb;
#
$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)
}
# 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 $sizeExistComp = 0;
my $nFilesTotal = 0;
my $sizeTotal = 0;
-my($logMsg, %stat, $xfer, $ShareNames);
+my($logMsg, %stat, $xfer, $ShareNames, $noFilesErr);
my $newFilesFH;
if ( $Conf{XferMethod} eq "tar" ) {
# Merge the xfer status (need to accumulate counts)
#
my $newStat = $xfer->getStats;
+ if ( $newStat->{fileCnt} == 0 ) {
+ $noFilesErr ||= "No files dumped for share $shareName";
+ }
foreach my $k ( (keys(%stat), keys(%$newStat)) ) {
next if ( !defined($newStat->{$k}) );
if ( $k =~ /Cnt$/ ) {
}
my $lastNum = -1;
+#
+# If this is a full, and any share had zero files then consider the dump bad
+#
+if ( $type eq "full" && $stat{hostError} eq ""
+ && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) {
+ $stat{hostError} = $noFilesErr;
+ $stat{xferOK} = 0;
+}
+
#
# Do one last check to make sure it is still the machine we expect.
#
# Now remove the bad files, replacing them if possible with links to
# earlier backups.
#
-foreach my $file ( $xfer->getBadFiles ) {
+foreach my $f ( $xfer->getBadFiles ) {
my $j;
- unlink("$Dir/$lastNum/$file");
+ my $shareM = $bpc->fileNameEltMangle($f->{share});
+ my $fileM = $bpc->fileNameMangle($f->{file});
+ unlink("$Dir/$lastNum/$shareM/$fileM");
for ( $j = $i - 1 ; $j >= 0 ; $j-- ) {
+ my $file;
+ if ( $Backups[$j]{mangle} ) {
+ $file = "$shareM/$fileM";
+ } else {
+ $file = "$f->{share}/$f->{file}";
+ }
next if ( !-f "$Dir/$Backups[$j]{num}/$file" );
- if ( !link("$Dir/$Backups[$j]{num}/$file", "$Dir/$lastNum/$file") ) {
+ if ( !link("$Dir/$Backups[$j]{num}/$file",
+ "$Dir/$lastNum/$shareM/$fileM") ) {
print(LOG $bpc->timeStamp,
- "Unable to link $lastNum/$file to"
+ "Unable to link $lastNum/$shareM/$fileM to"
. " $Backups[$j]{num}/$file\n");
} else {
print(LOG $bpc->timeStamp,
- "Bad file $lastNum/$file replaced by link to"
+ "Bad file $lastNum/$shareM/$fileM replaced by link to"
. " $Backups[$j]{num}/$file\n");
}
last;
}
if ( $j < 0 ) {
print(LOG $bpc->timeStamp,
- "Removed bad file $lastNum/$file (no older"
+ "Removed bad file $lastNum/$shareM/$fileM (no older"
. " copy to link to)\n");
}
}
XferLOG => $XferLOG,
stat => \%stat,
xferOK => $stat{xferOK} || 0,
+ hostError => $stat{hostError},
type => $type,
};
my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);