X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_dump;h=ce6afe22104b5550bd7b5a4d4735009e17ca22f0;hp=176c93a7d378d5cf2b64903c9e200d112a572c99;hb=d29fc837cef51c57811cd0805853a36dac9ea468;hpb=8d7768574bb328c669a44c6efbff01e8a7e93d7e diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index 176c93a..ce6afe2 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_dump: Dump a single client. @@ -70,7 +70,7 @@ # #======================================================================== # -# Version 2.0.0, released 14 Jun 2003. +# Version 2.0.2, released 6 Oct 2003. # # See http://backuppc.sourceforge.net. # @@ -78,7 +78,7 @@ 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; @@ -126,20 +126,19 @@ if ( $opts{d} ) { # $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); @@ -148,8 +147,8 @@ if ( $opts{d} ) { $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) } @@ -215,7 +214,7 @@ if ( !$opts{d} ) { # 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"); @@ -253,7 +252,7 @@ $bpc->ServerDisconnect(); 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); } @@ -385,7 +384,7 @@ my $sizeExist = 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" ) { @@ -637,6 +636,9 @@ for my $shareName ( @$ShareNames ) { # 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$/ ) { @@ -676,6 +678,15 @@ for my $shareName ( @$ShareNames ) { } 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. # @@ -768,25 +779,34 @@ unlink("$Dir/timeStamp.level0"); # 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"); } } @@ -997,6 +1017,7 @@ sub UserCommandRun XferLOG => $XferLOG, stat => \%stat, xferOK => $stat{xferOK} || 0, + hostError => $stat{hostError}, type => $type, }; my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);