From: cbarratt Date: Mon, 29 Dec 2008 11:46:13 +0000 (+0000) Subject: * Fixed encoding of email subject header in bin/BackupPC_sendEmail as X-Git-Tag: v3_2_0beta1~11 X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=f076585d3ff9dfe6de32292b897e293008efe74e * Fixed encoding of email subject header in bin/BackupPC_sendEmail as suggested by Jean-Claude Repetto. Also changed $Conf{EMailHeaders} charset to utf-8. Also changed bin/BackupPC_sendEmail to not send any per-client email if $Conf{BackupsDisable} is set. * Added server message for queuing a single host based on patch submitted by Joe Digilio. * Added $Conf{CmdQueueNice} to specify nice level for command queue commands (eg: BackupPC_link and BackupPC_nightly). Suggested by Carl Soderstrom. * Changed bin/BackupPC_dump to not ping or lookup the host if $Conf{BackupsDisable} is set. Requested by John Rouillard. * Added error check in BackupPC::Xfer::RsyncFileIO after call to BackupPC::Xfer::RsyncDigest->digestStart(), reported by Jeff Kosowsky. * Minor fix to sprintf arguments in BackupPC::Attrib, reported by Jonathan Kamens. * Fixed sort compareLOGName syntax in bin/BackupPC for perl 5.10.x, reported by Jeff Kosowsky and Holger Parplies. * Fixed bin/BackupPC_archiveStart to set compression correctly, and also set the file extension to .gz when compression is on. Reported by Stephen Vaughan. * Updated BackupPC.pod for $Conf{BackupsDisable}, reported by Nils Breunese. * Updates to makeDist for command-line setting of version and release date from Paul Mantz. * Add output from Pre/Post commands to per-client LOG file, in addition to existing output in the XferLOG file. Patch from Stuart Teasdale. * Removed BackupPC_compressPool and BackupPC::Xfer::BackupPCd. --- diff --git a/ChangeLog b/ChangeLog index 28ab594..3fca576 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,12 +31,21 @@ different xfer methods. Implemented by Paul Mantz. * Moved setting of $bpc->{PoolDir} and $bpc->{CPoolDir} after the - config file is read in BackupPC::Lib. Fix proposed by Tim Taylor - and Joe Krahn. + config file is read in BackupPC::Lib. Fix proposed by Tim Taylor + and Joe Krahn, and rediscovered by several others including + Holger Parplies. * Create $TopDir and related data directories in BackupPC_dump prior to hardlink test. Requested by Les Stott. +* Fixed encoding of email subject header in bin/BackupPC_sendEmail as + suggested by Jean-Claude Repetto. Also changed $Conf{EMailHeaders} + charset to utf-8. Also changed bin/BackupPC_sendEmail to not send + any per-client email if $Conf{BackupsDisable} is set. + +* Added server message for queuing a single host based on patch + submitted by Joe Digilio. + * Modified lib/BackupPC/CGI/RSS.pm to replace \n with \r\n in the RSS http response headers. Patch submitted by Thomas Eckhardt. @@ -50,19 +59,49 @@ name. That allows it to contain spaces and other special characters. Requested by Toni Van Remortel. +* Added $Conf{CmdQueueNice} to specify nice level for command queue + commands (eg: BackupPC_link and BackupPC_nightly). Suggested by + Carl Soderstrom. + * Added --config-override to configure.pl, allow config settings to be set on the command line. Proposed by Les Stott and Holger Parplies. +* Changed bin/BackupPC_dump to not ping or lookup the host if + $Conf{BackupsDisable} is set. Requested by John Rouillard. + +* Added error check in BackupPC::Xfer::RsyncFileIO after call to + BackupPC::Xfer::RsyncDigest->digestStart(), reported by Jeff + Kosowsky. + +* Minor fix to sprintf arguments in BackupPC::Attrib, reported by + Jonathan Kamens. + +* Fixed sort compareLOGName syntax in bin/BackupPC for perl 5.10.x, + reported by Jeff Kosowsky and Holger Parplies. + +* Fixed bin/BackupPC_archiveStart to set compression correctly, + and also set the file extension to .gz when compression is on. + Reported by Stephen Vaughan. + +* Updated BackupPC.pod for $Conf{BackupsDisable}, reported by + Nils Breunese. + * Minor updates to lib/BackupPC/Lang/fr.pm from Nicolas STRANSKY applied by GFK. * Minor updates to lib/BackupPC/Lang/de.pm from Klaus Weidenbach. -* lib/BackupPC/Xfer/Smb.pm now increments xferErrCnt on NT_STATUS_ACCESS_DENIED - and ERRnoaccess errors from smbclient. Reported by Jesús Martel. +* Updates to makeDist for command-line setting of version and + release date from Paul Mantz. + +* Add output from Pre/Post commands to per-client LOG file, in addition + to existing output in the XferLOG file. Patch from Stuart Teasdale. + +* lib/BackupPC/Xfer/Smb.pm now increments xferErrCnt on + NT_STATUS_ACCESS_DENIED and ERRnoaccess errors from smbclient. + Reported by Jesús Martel. -* Modified bin/BackupPC_sendEmail to not send any per-client email if - $Conf{BackupsDisable} is set. +* Removed BackupPC_compressPool and BackupPC::Xfer::BackupPCd. #------------------------------------------------------------------------ # Version 3.1.0, 25 Nov 2007 diff --git a/bin/BackupPC b/bin/BackupPC index d200f5a..f3df54a 100755 --- a/bin/BackupPC +++ b/bin/BackupPC @@ -47,7 +47,7 @@ # #======================================================================== # -# Version 3.1.0, released 25 Nov 2007. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -536,6 +536,7 @@ sub Main_TryToRun_CmdQueue if ( !$pid ) { setpgrp 0,0; $ENV{BPC_REQUSER} = $req->{user}; + POSIX::nice($Conf{CmdQueueNice}) if ( $Conf{CmdQueueNice} ); exec(@$cmd); print(LOG $bpc->timeStamp, "can't exec @$cmd for $host\n"); exit(0); @@ -1341,6 +1342,24 @@ sub Main_Check_Client_Messages QueueAllPCs(); } elsif ( $cmd =~ /^BackupPC_nightly run$/ ) { $RunNightlyWhenIdle = 1; + } elsif ( $cmd =~ /^queue (\S+)$/ ) { + $host = $1; + $host = $bpc->uriUnesc($host); + if ( !defined($Hosts->{$host}) ) { + print(LOG $bpc->timeStamp, + "User requested backup of unknown host $host\n"); + $reply = "error: unknown host $host"; + } else { + if ( QueueOnePC($host) ) { + print(LOG $bpc->timeStamp, + "Disk too full ($Info{DUlastValue}%); skipped 1 host\n"); + $Info{DUDailySkipHostCnt}++; + $reply = "error: disk too full to queue $host"; + } else { + print(LOG $bpc->timeStamp, "Host $host queued by user.\n"); + $reply = "ok: $host queued"; + } + } } elsif ( $cmd =~ /^backup (\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ ) { my $hostIP = $1; $host = $2; @@ -1348,7 +1367,7 @@ sub Main_Check_Client_Messages my $doFull = $4; $host = $bpc->uriUnesc($host); $hostIP = $bpc->uriUnesc($hostIP); - if ( !defined($Status{$host}) ) { + if ( !defined($Hosts->{$host}) ) { print(LOG $bpc->timeStamp, "User $user requested backup of unknown host" . " $host\n"); @@ -1413,7 +1432,7 @@ sub Main_Check_Client_Messages my $reqFileName = $4; $host = $bpc->uriUnesc($host); $hostIP = $bpc->uriUnesc($hostIP); - if ( !defined($Status{$host}) ) { + if ( !defined($Hosts->{$host}) ) { print(LOG $bpc->timeStamp, "User $user requested restore to unknown host" . " $host"); @@ -1609,7 +1628,6 @@ sub HostSortCompare # # Hosts with no errors go after hosts with errors # - return 1 if ( $Status{$a}{error} eq "" && $Status{$b}{error} ne "" ); # @@ -1624,6 +1642,65 @@ sub HostSortCompare return $a cmp $b; } +sub QueueOnePC +{ + my($host) = @_; + my $skipped = 0; + + delete($Status{$host}{backoffTime}) + if ( defined($Status{$host}{backoffTime}) + && $Status{$host}{backoffTime} < time ); + return if ( defined($Jobs{$host}) + || $BgQueueOn{$host} + || $UserQueueOn{$host} + || $CmdQueueOn{$host} ); + if ( $Hosts->{$host}{dhcp} ) { + $Status{$host}{dhcpCheckCnt}++; + if ( $RunNightlyWhenIdle ) { + # + # Once per night queue a check for DHCP hosts that just + # checks for expired dumps. We need to do this to handle + # the case when a DHCP host has not been on the network for + # a long time, and some of the old dumps need to be expired. + # Normally expiry checks are done by BackupPC_dump only + # after the DHCP hosts has been detected on the network. + # + unshift(@BgQueue, + {host => $host, user => "BackupPC", reqTime => time, + dhcp => 0, dumpExpire => 1}); + $BgQueueOn{$host} = 1; + } + } else { + # + # this is a fixed ip host: queue it + # + if ( $Info{DUlastValue} > $Conf{DfMaxUsagePct} ) { + # + # Since we are out of disk space, instead of queuing + # a regular job, queue an expire check instead. That + # way if the admin reduces the number of backups to + # keep then we will actually delete them. Otherwise + # BackupPC_dump will never run since we have exceeded + # the limit. + # + $skipped = 1; + unshift(@BgQueue, + {host => $host, user => "BackupPC", reqTime => time, + dhcp => $Hosts->{$host}{dhcp}, dumpExpire => 1}); + } else { + # + # Queue regular background backup + # + unshift(@BgQueue, + {host => $host, user => "BackupPC", reqTime => time, + dhcp => $Hosts->{$host}{dhcp}}); + } + $BgQueueOn{$host} = 1; + } + + return $skipped; +} + # # Queue all the hosts for backup. This means queuing all the fixed # ip hosts and all the dhcp address ranges. We also additionally @@ -1632,57 +1709,9 @@ sub HostSortCompare sub QueueAllPCs { my $nSkip = 0; + foreach my $host ( sort(HostSortCompare keys(%$Hosts)) ) { - delete($Status{$host}{backoffTime}) - if ( defined($Status{$host}{backoffTime}) - && $Status{$host}{backoffTime} < time ); - next if ( defined($Jobs{$host}) - || $BgQueueOn{$host} - || $UserQueueOn{$host} - || $CmdQueueOn{$host} ); - if ( $Hosts->{$host}{dhcp} ) { - $Status{$host}{dhcpCheckCnt}++; - if ( $RunNightlyWhenIdle ) { - # - # Once per night queue a check for DHCP hosts that just - # checks for expired dumps. We need to do this to handle - # the case when a DHCP host has not been on the network for - # a long time, and some of the old dumps need to be expired. - # Normally expiry checks are done by BackupPC_dump only - # after the DHCP hosts has been detected on the network. - # - unshift(@BgQueue, - {host => $host, user => "BackupPC", reqTime => time, - dhcp => 0, dumpExpire => 1}); - $BgQueueOn{$host} = 1; - } - } else { - # - # this is a fixed ip host: queue it - # - if ( $Info{DUlastValue} > $Conf{DfMaxUsagePct} ) { - # - # Since we are out of disk space, instead of queuing - # a regular job, queue an expire check instead. That - # way if the admin reduces the number of backups to - # keep then we will actually delete them. Otherwise - # BackupPC_dump will never run since we have exceeded - # the limit. - # - $nSkip++; - unshift(@BgQueue, - {host => $host, user => "BackupPC", reqTime => time, - dhcp => $Hosts->{$host}{dhcp}, dumpExpire => 1}); - } else { - # - # Queue regular background backup - # - unshift(@BgQueue, - {host => $host, user => "BackupPC", reqTime => time, - dhcp => $Hosts->{$host}{dhcp}}); - } - $BgQueueOn{$host} = 1; - } + $nSkip += QueueOnePC($host); } if ( $nSkip ) { print(LOG $bpc->timeStamp, diff --git a/bin/BackupPC_archiveStart b/bin/BackupPC_archiveStart index c7c9255..12553b5 100755 --- a/bin/BackupPC_archiveStart +++ b/bin/BackupPC_archiveStart @@ -35,7 +35,7 @@ # #======================================================================== # -# Version 3.1.0, released 25 Nov 2007. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -94,8 +94,9 @@ for ( my $i = 0 ; ; $i++ ) { my %ArchiveReq = ( archiveloc => $bpc->{Conf}{ArchiveDest}, archtype => 0, - compression => $bpc->{Conf}{CatPath}, - compext => '.raw', + compression => $bpc->{Conf}{ArchiveComp} eq "none" ? $bpc->{Conf}{CatPath} + : $bpc->{Conf}{ArchiveComp}, + compext => $bpc->{Conf}{ArchiveComp} eq "none" ? '.raw' : '.gz', parfile => $bpc->{Conf}{ArchivePar}, splitsize => '0000000', host => $ArchiveHost, diff --git a/bin/BackupPC_compressPool b/bin/BackupPC_compressPool deleted file mode 100755 index e9845ef..0000000 --- a/bin/BackupPC_compressPool +++ /dev/null @@ -1,631 +0,0 @@ -#!/bin/perl -#============================================================= -*-perl-*- -# -# BackupPC_compressPool: Compress existing pool -# -# DESCRIPTION -# -# Usage: BackupPC_compressPool [-t] [-r] -# -# Flags: -# -t test mode: do everything except actually replace the pool files. -# Useful for estimating total run time without making any real -# changes. -# -r read check: re-read the compressed file and compare it against -# the original uncompressed file. Can only be used in test mode. -# -c # number of children to fork. BackupPC_compressPool can take -# a long time to run, so to speed things up it spawns four children, -# each working on a different part of the pool. You can change -# the number of children with the -c option. -# -# BackupPC_compressPool is used to convert an uncompressed pool to -# a compressed pool. If BackupPC compression is enabled after -# uncompressed backups already exist, BackupPC_compressPool can -# be used to compress all the old uncompressed backups. -# -# It is important that BackupPC not run while BackupPC_compressPool -# runs. Also, BackupPC_compressPool must run to completion before -# BackupPC is restarted. -# -# AUTHOR -# Craig Barratt -# -# COPYRIGHT -# Copyright (C) 2001-2007 Craig Barratt -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#======================================================================== -# -# Version 3.1.0, released 25 Nov 2007. -# -# See http://backuppc.sourceforge.net. -# -#======================================================================== - -use strict; -no utf8; - -use File::Find; -use File::Path; -use Compress::Zlib; -use Getopt::Std; -use lib "/usr/local/BackupPC/lib"; -use BackupPC::Lib; -use BackupPC::FileZIO; - -die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); -$bpc->ChildInit(); -my $TopDir = $bpc->TopDir(); -my $LogDir = $bpc->LogDir(); -my $BinDir = $bpc->BinDir(); -my %Conf = $bpc->Conf(); -my $PoolDir = "$TopDir/pool"; -my $CPoolDir = "$TopDir/cpool"; -my $Compress = $Conf{CompressLevel}; -my %opts; -my $SigName = ""; - -# -# Catch various signals -# -foreach my $sig ( qw(INT BUS SEGV PIPE TERM ALRM HUP) ) { - $SIG{$sig} = \&catch_signal; -} - -$| = 1; - -my $CompMaxRead = 131072; # 128K -my $CompMaxWrite = 6291456; # 6MB - -if ( !getopts("trc:", \%opts) || @ARGV != 0 ) { - print("usage: $0 [-c nChild] [-r] [-t]\n"); - exit(1); -} -my $TestMode = $opts{t}; -my $ReadCheck = $opts{r}; -my $nChild = $opts{c} || 4; -if ( $ReadCheck && !$TestMode ) { - print(STDERR "$0: -r (read check) option must have -t (test)\n"); - exit(1); -} -if ( $nChild < 1 || $nChild >= 16 ) { - print(STDERR "$0: number of children (-c option) must be from 1 to 16\n"); - exit(1); -} -if ( !BackupPC::FileZIO->compOk ) { - print STDERR <ServerConnect($Conf{ServerHost}, $Conf{ServerPort}); -if ( $err eq "" ) { - print < 65536, - -Level => $Compress, - ); - if ( !open(FH, $TestMode ? "<" : "+<", $file) ) { - print("Error: Can't open $file for read/write\n"); - $Errors++; - return; - } - binmode(FH); - while ( sysread(FH, $dataIn, $CompMaxWrite) > 0 ) { - $flush = 0; - $FileOrigSz += length($dataIn); - my $fragOut = $defl->deflate($dataIn); - if ( length($fragOut) < $CompMaxRead ) { - # - # Compression is too high: to avoid huge memory requirements - # on read we need to flush(). - # - $fragOut .= $defl->flush(); - $flush = 1; - $defl = deflateInit( - -Bufsize => 65536, - -Level => $Compress, - ); - } - $dataOut .= $fragOut; - if ( !$copy && length($dataOut) > $CompMaxWrite ) { - if ( !open(OUT, "+>", "$file.__z") ) { - print("Error: Can't open $file.__z for write\n"); - $Errors++; - close(FH); - return; - } - binmode(OUT); - $copy = 1; - } - if ( $copy && $dataOut ne "" ) { - if ( syswrite(OUT, $dataOut) != length($dataOut) ) { - printf("Error: Can't write %d bytes to %s\n", - length($dataOut), "$file.__z"); - $Errors++; - close(OUT); - close(FH); - unlink("$file.__z"); - return; - } - $FileCompressSz += length($dataOut); - $dataOut = undef; - } - } - if ( !$flush ) { - $dataOut .= $defl->flush(); - if ( $copy && $dataOut ne "" ) { - if ( syswrite(OUT, $dataOut) != length($dataOut) ) { - printf("Error: Can't write %d bytes to %s\n", - length($dataOut), "$file.__z"); - $Errors++; - close(OUT); - close(FH); - unlink("$file.__z"); - return; - } - $FileCompressSz += length($dataOut); - $dataOut = undef; - } - } - my $newFile = cpoolFileName($file); - if ( $TestMode ) { - close(FH); - if ( !open(FH, ">", $newFile) ) { - print("Error: Can't open $newFile for write\n"); - $Errors++; - close(FH); - unlink("$file.__z"); - return; - } - binmode(FH); - } - if ( $copy ) { - if ( !sysseek(OUT, 0, 0) ) { - print("Error: Can't seek $file.__z to 0\n"); - $Errors++; - } - if ( !sysseek(FH, 0, 0) ) { - print("Error: Can't seek $newFile to 0\n"); - $Errors++; - } - while ( sysread(OUT, $dataIn, $CompMaxWrite) > 0 ) { - if ( syswrite(FH, $dataIn) != length($dataIn) ) { - printf("Error: Can't write %d bytes to %s\n", - length($dataIn), $file); - $Errors++; - } - } - if ( !truncate(FH, sysseek(OUT, 0, 1)) ) { - printf("Error: Can't truncate %s to %d\n", - $file, sysseek(OUT, 0, 1)); - $Errors++; - } - close(OUT); - close(FH); - unlink("$file.__z"); - } else { - if ( !sysseek(FH, 0, 0) ) { - print("Error: Can't seek $file to 0\n"); - $Errors++; - } - if ( syswrite(FH, $dataOut) != length($dataOut) ) { - printf("Error: Can't write %d bytes to %s\n", - length($dataOut), $file); - $Errors++; - } - $FileCompressSz += length($dataOut); - if ( !truncate(FH, length($dataOut)) ) { - printf("Error: Can't truncate %s to %d\n", $file, length($dataOut)); - $Errors++; - } - close(FH); - } - if ( $TestMode ) { - if ( $ReadCheck ) { - checkRead($file, $newFile); - } - unlink($newFile); - } else { - rename($file, $newFile); - my $atime = $s[8] =~ /(.*)/ && $1; - my $mtime = $s[9] =~ /(.*)/ && $1; - utime($atime, $mtime, $newFile); - } - (my $dir = $file) =~ s{/[^/]*$}{}; - $FileCnt++; - if ( $SubDirCurr ne "" && $SubDirCurr ne $dir ) { - $SubDirDone++; - $SubDirCurr = $dir; - reportStats(); - } elsif ( $SubDirCurr eq "" ) { - $SubDirCurr = $dir; - } -} - -sub reportStats -{ - print("stats: $SubDirDone $SubDirCnt $FileCnt $FileOrigSz" - . " $FileCompressSz $Errors\n"); -} - -sub checkRead -{ - my($file, $cfile) = @_; - return if ( !-f $file || !-f $cfile ); - my $f = BackupPC::FileZIO->open($cfile, 0, $Compress) - || die("can't open $cfile for read\n"); - my($n, $nd, $r, $d, $d0); - local(*FH); - - if ( !open(FH, "<", $file) ) { - print("can't open $file for check\n"); - $Errors++; - $f->close(); - return; - } - binmode(FH); - #print("comparing $file to $cfile\n"); - while ( 1 ) { - $n = 1 + int(rand($CompMaxRead) + rand(100)); - $r = $f->read(\$d, $n); - sysread(FH, $d0, $n); - if ( $d ne $d0 ) { - print("Botch read data on $cfile\n"); - } - last if ( length($d) == 0 ); - } - if ( ($r = $f->read(\$d, 100)) != 0 || ($r = $f->read(\$d, 100)) != 0 ) { - printf("Botch at EOF on $cfile got $r (%d,%d)\n", - sysseek(FH, 0, 1), $n); - $Errors++; - } - $f->close; - close(FH); -} - -sub checkReadLine -{ - my($file, $cfile) = @_; - return if ( !-f $file || !-f $cfile ); - my $f = BackupPC::FileZIO->open($cfile, 0, $Compress) - || die("can't open $cfile for read\n"); - my($n, $nd, $r, $d, $d0); - local(*FH); - - if ( !open(FH, "<", $file) ) { - print("can't open $file for check\n"); - $Errors++; - $f->close(); - return; - } - binmode(FH); - while ( 1 ) { - $d0 = ; - $d = $f->readLine(); - if ( $d ne $d0 ) { - print("Botch read data on $cfile\n"); - } - last if ( length($d) == 0 ); - } - if ( ($r = $f->read(\$d, 100)) != 0 || ($r = $f->read(\$d, 100)) != 0 ) { - printf("Botch at EOF on $cfile got $r (%d,%d)\n", - sysseek(FH, 0, 1), $n); - $Errors++; - } - $f->close; - close(FH); -} - -sub catch_signal -{ - $SigName = shift; -} - -sub compressHostFiles -{ - my($host) = @_; - my(@Files, @Backups, $fh, $data); - local(*FH); - - if ( !defined($host) ) { - for ( my $i = 0 ; ; $i++ ) { - last if ( !-f "$LogDir/LOG.$i" ); - push(@Files, "$LogDir/LOG.$i"); - } - } else { - @Backups = $bpc->BackupInfoRead($host); - for ( my $i = 0 ; $i < @Backups ; $i++ ) { - next if ( $Backups[$i]{compress} ); - push(@Files, "$TopDir/pc/$host/SmbLOG.$Backups[$i]{num}"); - push(@Files, "$TopDir/pc/$host/XferLOG.$Backups[$i]{num}"); - } - push(@Files, "$TopDir/pc/$host/SmbLOG.bad"); - push(@Files, "$TopDir/pc/$host/XferLOG.bad"); - for ( my $i = 0 ; ; $i++ ) { - last if ( !-f "$TopDir/pc/$host/LOG.$i" ); - push(@Files, "$TopDir/pc/$host/LOG.$i"); - } - } - foreach my $file ( @Files ) { - if ( $SigName ) { - print("Child got signal $SigName; quitting\n"); - reportStats(); - exit(0); - } - next if ( !-f $file ); - if ( !BackupPC::FileZIO->compressCopy($file, "$file.z", undef, - $Compress, !$TestMode) ) { - print("compressCopy($file, $file.z, $Compress, !$TestMode)" - . " failed\n"); - $Errors++; - } elsif ( $TestMode ) { - checkReadLine($file, "$file.z") if ( $ReadCheck ); - unlink("$file.z"); - } - } -} - -sub updateHostBackupInfo -{ - my($host) = @_; - if ( !$TestMode ) { - my @Backups = $bpc->BackupInfoRead($host); - for ( my $i = 0 ; $i < @Backups ; $i++ ) { - $Backups[$i]{compress} = $Compress; - } - $bpc->BackupInfoWrite($host, @Backups); - } -} - -my @Dirs = split(//, "0123456789abcdef"); -my @Hosts = sort(keys(%{$bpc->HostInfoRead()})); -my $FDread; -my @Jobs; - -# -# First make sure there are no existing compressed backups -# -my(%compHosts, $compCnt); -for ( my $j = 0 ; $j < @Hosts ; $j++ ) { - my $host = $Hosts[$j]; - my @Backups = $bpc->BackupInfoRead($host); - for ( my $i = 0 ; $i < @Backups ; $i++ ) { - next if ( !$Backups[$i]{compress} ); - $compHosts{$host}++; - $compCnt++; - } -} -if ( $compCnt ) { - my $compHostStr = join("\n + ", sort(keys(%compHosts))); - print STDERR < ) { - next if ( !opendir(DIR, $dir) ); - my @files = readdir(DIR); - closedir(DIR); - $SubDirCnt++ if ( @files > 2 ); - } - } - # - # Now process each of the directories - # - for ( my $j = 0 ; $j < $nDirs ; $j++ ) { - my $thisDir = shift(@Dirs); - next if ( !-d "$PoolDir/$thisDir" ); - find({wanted => sub { doCompress($File::Find::name); }, - no_chdir => 1}, "$PoolDir/$thisDir"); - } - # - # Last, update the backup info file for each of the hosts - # - for ( my $j = 0 ; $j < $nHosts ; $j++ ) { - updateHostBackupInfo($Hosts[$j]); - } - $SubDirDone = $SubDirCnt; - reportStats(); - exit(0); - } - # - # This is the parent. Peel off $nDirs directories, $nHosts hosts, - # and continue - # - $Jobs[$i]{fh} = *CHILD; - $Jobs[$i]{pid} = $pid; - vec($FDread, fileno($Jobs[$i]{fh}), 1) = 1; - splice(@Dirs, 0, $nDirs); - splice(@Hosts, 0, $nHosts); -} - -# -# compress the main log files (in the parents) -# -compressHostFiles(undef); - -# -# Now wait for all the children to report results and finish up -# -my $TimeStart = time; -my $DonePct = 0; -my $GotSignal = ""; -while ( $FDread !~ /^\0*$/ ) { - my $ein = $FDread; - select(my $rout = $FDread, undef, $ein, undef); - if ( $SigName ne $GotSignal ) { - print("Got signal $SigName; waiting for $nChild children to cleanup\n"); - $GotSignal = $SigName; - } - for ( my $i = 0 ; $i < $nChild ; $i++ ) { - next if ( !vec($rout, fileno($Jobs[$i]{fh}), 1) ); - my $data; - if ( sysread($Jobs[$i]{fh}, $data, 1024) <= 0 ) { - vec($FDread, fileno($Jobs[$i]{fh}), 1) = 0; - close($Jobs[$i]{fh}); - next; - } - $Jobs[$i]{mesg} .= $data; - while ( $Jobs[$i]{mesg} =~ /(.*?)[\n\r]+(.*)/s ) { - my $mesg = $1; - $Jobs[$i]{mesg} = $2; - if ( $mesg =~ /^stats: (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/ ) { - $Jobs[$i]{SubDirDone} = $1; - $Jobs[$i]{SubDirCnt} = $2; - $Jobs[$i]{FileCnt} = $3; - $Jobs[$i]{FileOrigSz} = $4; - $Jobs[$i]{FileCompressSz} = $5; - $Jobs[$i]{Errors} = $6; - $SubDirDone = $SubDirCnt = $FileCnt = $FileOrigSz = 0; - $FileCompressSz = $Errors = 0; - my $numReports = 0; - for ( my $j = 0 ; $j < $nChild ; $j++ ) { - next if ( !defined($Jobs[$j]{SubDirDone}) ); - $SubDirDone += $Jobs[$j]{SubDirDone}; - $SubDirCnt += $Jobs[$j]{SubDirCnt}; - $FileCnt += $Jobs[$j]{FileCnt}; - $FileOrigSz += $Jobs[$j]{FileOrigSz}; - $FileCompressSz += $Jobs[$j]{FileCompressSz}; - $Errors += $Jobs[$j]{Errors}; - $numReports++; - } - $SubDirCnt ||= 1; - $FileOrigSz ||= 1; - my $pctDone = 100 * $SubDirDone / $SubDirCnt; - if ( $numReports == $nChild && $pctDone >= $DonePct + 1 ) { - $DonePct = int($pctDone); - my $estSecLeft = 1.2 * (time - $TimeStart) - * (100 / $pctDone - 1); - my $timeStamp = $bpc->timeStamp; - printf("%sDone %2.0f%% (%d of %d dirs, %d files," - . " %.2fGB raw, %.1f%% reduce, %d errors)\n", - $timeStamp, - $pctDone, $SubDirDone, $SubDirCnt, $FileCnt, - $FileOrigSz / (1024 * 1024 * 1000), - 100 * (1 - $FileCompressSz / $FileOrigSz)); - printf("%s Est complete in %.1f hours (around %s)\n", - $timeStamp, $estSecLeft / 3600, - $bpc->timeStamp(time + $estSecLeft, 1)) - if ( $DonePct < 100 ); - } - } else { - print($mesg, "\n"); - } - } - } -} -if ( $Errors ) { - print("Finished with $Errors errors!!!!\n"); - exit(1); -} diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index 3e212d0..0971f9e 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -70,7 +70,7 @@ # #======================================================================== # -# Version 3.1.0, released 25 Nov 2007. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -234,7 +234,7 @@ if ($Conf{XferMethod} eq "archive" ) { exit(0); } -if ( !$opts{d} ) { +if ( !$opts{d} && !$Conf{BackupsDisable} ) { # # In the non-DHCP case, make sure the host can be looked up # via NS, or otherwise find the IP address via NetBios. @@ -1628,6 +1628,7 @@ sub UserCommandRun $bpc->cmdSystemOrEval($cmd, sub { $XferLOG->write(\$_[0]); + print(LOG $bpc->timeStamp, "Output from $cmdType: ", $_[0]); }, $vars, \%Conf); } diff --git a/bin/BackupPC_sendEmail b/bin/BackupPC_sendEmail index 055884a..cea4161 100755 --- a/bin/BackupPC_sendEmail +++ b/bin/BackupPC_sendEmail @@ -31,7 +31,7 @@ # #======================================================================== # -# Version 3.1.0, released 25 Nov 2007. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -373,7 +373,7 @@ sub sendUserEmail $vars->{domain} = $Conf{EMailUserDestDomain}; $vars->{CgiURL} = $Conf{CgiURL}; $subj =~ s/\$(\w+)/defined($vars->{$1}) ? $vars->{$1} : "\$$1"/eg; - $vars->{subj} = $subj; + $vars->{subj} = encode('MIME-Header', $subj); $mesg =~ s/\$(\w+)/defined($vars->{$1}) ? $vars->{$1} : "\$$1"/eg; SendMail($mesg); $UserEmailInfo{$user}{lastTime} = time; @@ -403,13 +403,7 @@ sub SendMail printf("Can't run sendmail ($Conf{SendmailPath}): $!\n"); return; } - if ( $utf8 ) { - binmode(MAIL, ":utf8"); - if ($mesg =~ /^Subject: (.*)$/m) { - my $new_subj = encode('MIME-Header', $1); - $mesg =~ s/^Subject: .*$/Subject: $new_subj/m; - } - } + binmode(MAIL, ":utf8") if ( $utf8 ); print MAIL $mesg; close(MAIL); } diff --git a/conf/config.pl b/conf/config.pl index abdcd32..c7e17bb 100644 --- a/conf/config.pl +++ b/conf/config.pl @@ -136,7 +136,13 @@ $Conf{MaxUserBackups} = 4; # This limit is to make sure BackupPC doesn't fall too far behind in # running BackupPC_link commands. # -$Conf{MaxPendingCmds} = 10; +$Conf{MaxPendingCmds} = 15; + +# +# Nice level at which CmdQueue commands (eg: BackupPC_link and +# BackupPC_nightly) are run at. +# +$Conf{CmdQueueNice} = 10; # # How many BackupPC_nightly processes to run in parallel. @@ -288,6 +294,14 @@ $Conf{BackupPCUser} = ''; # with configure.pl to change InstallDir. # CgiDir - Apache CGI directory for BackupPC_Admin # +# Note: it is STRONGLY recommended that you don't change the +# values here. These are set at installation time and are here +# for reference and are used during upgrades. +# +# Instead of changing TopDir here it is recommended that you use +# a symbolic link to the new location, or mount the new BackupPC +# store at the existing $Conf{TopDir} setting. +# $Conf{TopDir} = ''; $Conf{ConfDir} = ''; $Conf{LogDir} = ''; @@ -1398,71 +1412,6 @@ $Conf{FtpTimeout} = 120; # $Conf{FtpFollowSymlinks} = 0; - -########################################################################### -# BackupPCd Configuration -# (can be overwritten in the per-PC log file) -########################################################################### -# -# Share name to backup. For $Conf{XferMethod} = "backuppcd" this should -# be a file system path, eg '/' or '/home'. -# -# This can also be a list of multiple file system paths or modules. -# (Can it??) -# -# $Conf{BackupPCdShareName} = ['/', '/var', '/data', '/boot']; -# -$Conf{BackupPCdShareName} = '/'; - -# -# Path to backuppcd executable on the server -# -$Conf{BackupPCdPath} = ''; - -# -# Full command to run backuppcd on the server to backup a given -# client machine. The following variables are substituted at -# run-time (TODO: update this list) -# -# $host host name being backed up -# $hostIP host's IP address -# $shareName share name to backup (ie: top-level directory path) -# $backuppcdPath same as $Conf{BackupPCdPath} -# $sshPath same as $Conf{SshPath} -# -# This setting only matters if $Conf{XferMethod} = 'backuppcd'. -# -# Arguments to backupcpd are: -# -# - the host name to backup -# - the share name to backup -# - the directory where the pool is -# - the directory where the last run was (NOT DONE YET) -# - a boolean value indicating whether or not the pool is -# compressed or not -# - the directory where the new run should occur (currently it assumes ".") -# -$Conf{BackupPCdCmd} = '$bpcdPath $host $shareName $poolDir XXXX $poolCompress $topDir/pc/$client/new'; - -# -# Full command to run backuppcd on the server for restore to a -# client machine. The following variables are substituted at -# run-time (TODO: update this list) -# -# $host host name being backed up -# $hostIP host's IP address -# $shareName share name to backup (ie: top-level directory path) -# $backuppcdPath same as $Conf{BackupPCdPath} -# $sshPath same as $Conf{SshPath} -# -# This setting only matters if $Conf{XferMethod} = 'backuppcd'. -# -# Note: all Cmds are executed directly without a shell, so the prog name -# needs to be a full path and you can't include shell syntax like -# redirection and pipes; put that in a script if you need it. -# -$Conf{BackupPCdRestoreCmd} = '$bpcdPath TODO'; - ########################################################################### # Archive Configuration # (can be overwritten in the per-PC log file) @@ -1962,13 +1911,12 @@ $Conf{EMailOutlookBackupSubj} = undef; $Conf{EMailOutlookBackupMesg} = undef; # -# Additional email headers. If you change the charset -# to utf8 then BackupPC_sendEmail will use utf8 for -# the email body. +# Additional email headers. This sets to charset to +# utf8. # $Conf{EMailHeaders} = < 1, FtpPort => 1, FtpTimeout => 1, - BackupPCdPath => 1, - BackupPCdShareName => 1, - BackupPCdCmd => 1, - BackupPCdRestoreCmd => 1, ArchiveDest => 1, ArchiveComp => 1, ArchivePar => 1, diff --git a/configure.pl b/configure.pl index e0923d2..4b97fa7 100755 --- a/configure.pl +++ b/configure.pl @@ -407,10 +407,8 @@ BackupPC can compress pool files, but it needs the Compress::Zlib package installed (see www.cpan.org). Compression will provide around a 40% reduction in pool size, at the expense of cpu time. You can leave compression off and run BackupPC without compression, in which case you -should leave the compression level at 0 (which means off). You could -install Compress::Zlib and turn compression on later, but read the -documentation first about how to do this. Or the better choice is -to quit, install Compress::Zlib, and re-run configure.pl. +should leave the compression level at 0 (which means off). Or the better +choice is to quit, install Compress::Zlib, and re-run configure.pl. EOF } elsif ( $Conf{CompressLevel} ) { @@ -418,14 +416,12 @@ EOF print <{type} ) { - $a->{_errStr} = sprintf("Wrong magic number in $file" + $a->{_errStr} = sprintf("Wrong magic number in %s" . " (got 0x%x, expected 0x%x)", - $magic, $a->{type}); + $file, $magic, $a->{type}); $fd->close; return; } diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index 9b78b15..466ab13 100644 --- a/lib/BackupPC/CGI/EditConfig.pm +++ b/lib/BackupPC/CGI/EditConfig.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.1.1, released 22 Dec 2008. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -73,6 +73,7 @@ our %ConfigMenu = ( {name => "UmaskMode"}, {name => "MyPath"}, {name => "DHCPAddressRanges"}, + {name => "CmdQueueNice"}, {name => "PerlModuleLoad"}, {name => "ServerInitdPath"}, {name => "ServerInitdStartCmd"}, @@ -223,18 +224,6 @@ our %ConfigMenu = ( {name => "FtpFollowSymlinks", visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, - ### BackupPCd Settings - {text => "CfgEdit_Title_BackupPCd_Settings", - visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, - {name => "BackupPCdShareName", - visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, - {name => "BackupPCdPath", - visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, - {name => "BackupPCdCmd", - visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, - {name => "BackupPCdRestoreCmd", - visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, - ### Archive Settings {text => "CfgEdit_Title_Archive_Settings", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, diff --git a/lib/BackupPC/Config/Meta.pm b/lib/BackupPC/Config/Meta.pm index 17833c7..76b8b49 100644 --- a/lib/BackupPC/Config/Meta.pm +++ b/lib/BackupPC/Config/Meta.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.1.1, released 22 Dec 2008. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -80,6 +80,7 @@ use vars qw(%ConfigMeta); MaxBackupPCNightlyJobs => "integer", BackupPCNightlyPeriod => "integer", MaxOldLogFiles => "integer", + CmdQueueNice => "integer", SshPath => {type => "execPath", undefIfEmpty => 1}, NmbLookupPath => {type => "execPath", undefIfEmpty => 1}, @@ -277,17 +278,6 @@ use vars qw(%ConfigMeta); FtpTimeout => "integer", FtpFollowSymlinks => "boolean", - ###################################################################### - # BackupPCd Configuration - ###################################################################### - BackupPCdShareName => { - type => "list", - child => "string", - }, - BackupPCdCmd => "string", - BackupPCdPath => "string", - BackupPCdRestoreCmd => "string", - ###################################################################### # Archive Configuration ###################################################################### @@ -455,10 +445,6 @@ use vars qw(%ConfigMeta); FtpBlockSize => "boolean", FtpPort => "boolean", FtpTimeout => "boolean", - BackupPCdShareName => "boolean", - BackupPCdCmd => "boolean", - BackupPCdPath => "boolean", - BackupPCdRestoreCmd => "boolean", ArchiveDest => "boolean", ArchiveComp => "boolean", ArchivePar => "boolean", diff --git a/lib/BackupPC/Lang/de.pm b/lib/BackupPC/Lang/de.pm index 06673ad..cf3d436 100644 --- a/lib/BackupPC/Lang/de.pm +++ b/lib/BackupPC/Lang/de.pm @@ -1392,7 +1392,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Tar Einstellungen"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Einstellungen"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Einstellungen"; $Lang{CfgEdit_Title_Ftp_Settings} = "FTP Einstellungen"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Einstellungen"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Einstellungen"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Pfade/Kommandos"; diff --git a/lib/BackupPC/Lang/en.pm b/lib/BackupPC/Lang/en.pm index 6154232..7b75881 100644 --- a/lib/BackupPC/Lang/en.pm +++ b/lib/BackupPC/Lang/en.pm @@ -1384,7 +1384,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; $Lang{CfgEdit_Title_Ftp_Settings} = "FTP Settings"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/es.pm b/lib/BackupPC/Lang/es.pm index 25bb73a..34d933f 100644 --- a/lib/BackupPC/Lang/es.pm +++ b/lib/BackupPC/Lang/es.pm @@ -1388,7 +1388,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; $Lang{CfgEdit_Title_Ftp_Settings} = "FTP Settings"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/fr.pm b/lib/BackupPC/Lang/fr.pm index 0109692..d66b604 100644 --- a/lib/BackupPC/Lang/fr.pm +++ b/lib/BackupPC/Lang/fr.pm @@ -1385,7 +1385,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Param $Lang{CfgEdit_Title_Rsync_Settings} = "Paramètres de Rsync"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Paramètres de Rsyncd"; $Lang{CfgEdit_Title_Ftp_Settings} = "Paramètres de FTP"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "Paramètres de BackupPCd"; $Lang{CfgEdit_Title_Archive_Settings} = "Paramètres d'archivage"; $Lang{CfgEdit_Title_Include_Exclude} = "Inclure/Exclure"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Chemins/Commandes Smb"; diff --git a/lib/BackupPC/Lang/it.pm b/lib/BackupPC/Lang/it.pm index f9b81fb..78c5974 100644 --- a/lib/BackupPC/Lang/it.pm +++ b/lib/BackupPC/Lang/it.pm @@ -1399,7 +1399,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Configurazione Tar"; $Lang{CfgEdit_Title_Rsync_Settings} = "Configurazione Rsync"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Configurazione Rsyncd"; $Lang{CfgEdit_Title_Ftp_Settings} = "Configurazione FTP"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "Configurazione BackupPCd"; $Lang{CfgEdit_Title_Archive_Settings} = "Configurazione Archivi"; $Lang{CfgEdit_Title_Include_Exclude} = "Includi/Escludi"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Percorsi/Comandi"; diff --git a/lib/BackupPC/Lang/nl.pm b/lib/BackupPC/Lang/nl.pm index 943ebe5..291a7be 100644 --- a/lib/BackupPC/Lang/nl.pm +++ b/lib/BackupPC/Lang/nl.pm @@ -1397,7 +1397,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Tar instellingen"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync instellingen"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd instellingen"; $Lang{CfgEdit_Title_Ftp_Settings} = "FTP instellingen"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd instellingen"; $Lang{CfgEdit_Title_Archive_Settings} = "Archivering instellingen"; $Lang{CfgEdit_Title_Include_Exclude} = "Inclusief/Exclusief"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Pad/Opdrachten"; diff --git a/lib/BackupPC/Lang/pl.pm b/lib/BackupPC/Lang/pl.pm index 9963371..55425c5 100644 --- a/lib/BackupPC/Lang/pl.pm +++ b/lib/BackupPC/Lang/pl.pm @@ -1378,7 +1378,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Ustawienia Tar"; $Lang{CfgEdit_Title_Rsync_Settings} = "Ustawienia Rsync"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Ustawienia Rsyncd"; $Lang{CfgEdit_Title_Ftp_Settings} = "Ustawienia FTP"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "Ustawienia BackupPCd"; $Lang{CfgEdit_Title_Archive_Settings} = "Ustawienia Archiwizacji"; $Lang{CfgEdit_Title_Include_Exclude} = "Dodaj/Usuń"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Ściezki/Polecenia Smb"; diff --git a/lib/BackupPC/Lang/pt_br.pm b/lib/BackupPC/Lang/pt_br.pm index ec3c06b..b698044 100644 --- a/lib/BackupPC/Lang/pt_br.pm +++ b/lib/BackupPC/Lang/pt_br.pm @@ -1388,7 +1388,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Configura $Lang{CfgEdit_Title_Rsync_Settings} = "Configurações do Rsync"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Configurações do Rsyncd"; $Lang{CfgEdit_Title_Ftp_Settings} = "Configurações do FTP"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "Configurações do BackupPCd"; $Lang{CfgEdit_Title_Archive_Settings} = "Configurações do Archive"; $Lang{CfgEdit_Title_Include_Exclude} = "Inclui/Exclui"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Caminhos/Comandos do Smb"; diff --git a/lib/BackupPC/Lang/zh_CN.pm b/lib/BackupPC/Lang/zh_CN.pm index 24c97e6..5bce4d0 100644 --- a/lib/BackupPC/Lang/zh_CN.pm +++ b/lib/BackupPC/Lang/zh_CN.pm @@ -1352,7 +1352,6 @@ $Lang{CfgEdit_Title_Tar_Settings} = "Tar 设置"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync 设置"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd 设置"; $Lang{CfgEdit_Title_Ftp_Settings} = "FTP 设置"; -$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd 设置"; $Lang{CfgEdit_Title_Archive_Settings} = "备档设置"; $Lang{CfgEdit_Title_Include_Exclude} = "包含/排除"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb 路径/命令"; diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index 8665c29..e5cb98a 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -1218,7 +1218,7 @@ sub cmdVarSubstitute } } # - # Merge variables into @tarClientCmd + # Merge variables into @cmd # foreach my $arg ( @$template ) { # diff --git a/lib/BackupPC/Xfer.pm b/lib/BackupPC/Xfer.pm index b585e25..2977015 100644 --- a/lib/BackupPC/Xfer.pm +++ b/lib/BackupPC/Xfer.pm @@ -43,7 +43,6 @@ use strict; use Encode qw/from_to encode/; use BackupPC::Xfer::Archive; -use BackupPC::Xfer::BackupPCd; use BackupPC::Xfer::Ftp; use BackupPC::Xfer::Protocol; use BackupPC::Xfer::Rsync; @@ -65,12 +64,6 @@ sub create $errStr = BackupPC::Xfer::Archive::errStr() if ( !defined($xfer) ); return $xfer; - } elsif ( $protocol eq 'backuppcd' ) { - - $xfer = BackupPC::Xfer::BackupPCd->new( $bpc, $args ); - $errStr = BackupPC::Xfer::BackupPCd::errStr() if ( !defined($xfer) ); - return $xfer; - } elsif ( $protocol eq 'ftp' ) { $xfer = BackupPC::Xfer::Ftp->new( $bpc, $args ); @@ -127,9 +120,6 @@ sub getShareNames } elsif ( $conf->{XferMethod} eq "rsync" || $conf->{XferMethod} eq "rsyncd" ) { $ShareNames = $conf->{RsyncShareName}; - } elsif ( $conf->{XferMethod} eq "backuppcd" ) { - $ShareNames = $conf->{BackupPCdShareName}; - } elsif ( $conf->{XferMethod} eq "smb" ) { $ShareNames = $conf->{SmbShareName}; diff --git a/lib/BackupPC/Xfer/BackupPCd.pm b/lib/BackupPC/Xfer/BackupPCd.pm deleted file mode 100644 index e6dd5b0..0000000 --- a/lib/BackupPC/Xfer/BackupPCd.pm +++ /dev/null @@ -1,211 +0,0 @@ -#============================================================= -*-perl-*- -# -# BackupPC::Xfer::BackupPCd package -# -# DESCRIPTION -# -# This library defines a BackupPC::Xfer::BackupPCd class for managing -# the backuppcd-based transport of backup data from the client. -# -# AUTHOR -# Craig Barratt -# -# COPYRIGHT -# Copyright (C) 2006-2007 Craig Barratt -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#======================================================================== -# -# Version 3.1.0, released 25 Nov 2007. -# -# See http://backuppc.sourceforge.net. -# -#======================================================================== - -package BackupPC::Xfer::BackupPCd; - -use strict; -use base qw(BackupPC::Xfer::Protocol); - -sub new -{ - my($class, $bpc, $args) = @_; - - $args ||= {}; - my $t = bless { - bpc => $bpc, - conf => { $bpc->Conf }, - host => "", - hostIP => "", - shareName => "", - badFiles => [], - - # - # Various stats - # - byteCnt => 0, - fileCnt => 0, - xferErrCnt => 0, - xferBadShareCnt => 0, - xferBadFileCnt => 0, - xferOK => 0, - - # - # User's args - # - %$args, - }, $class; - - return $t; -} - -sub start -{ - my($t) = @_; - my $bpc = $t->{bpc}; - my $conf = $t->{conf}; - my(@fileList, $bpcdCmd, $bpcdArgs, $logMsg, $incrDate, - $incrFlag, $restoreDir); - - # - # We add a slash to the share name we pass to bpcd - # - ($t->{shareNameSlash} = "$t->{shareName}/") =~ s{//+$}{/}; - - if ( $t->{type} eq "restore" ) { - $bpcdCmd = $conf->{BackupPCdRestoreCmd}; - $restoreDir = "$t->{shareName}/$t->{pathHdrDest}"; - $restoreDir =~ s{//+}{/}g; - $logMsg = "restore started below directory $t->{shareName}" - . " to host $t->{host}"; - } else { - if ( $t->{type} eq "full" ) { - if ( $t->{partialNum} ) { - $logMsg = "full backup started for directory $t->{shareName};" - . " updating partial $t->{partialNum}"; - } else { - $logMsg = "full backup started for directory $t->{shareName}"; - } - $incrFlag = 0; - } else { - # - # TODO: fix this message - just refer to the backup, not time? - # - $incrDate = $bpc->timeStamp($t->{incrBaseTime} - 3600, 1); - $logMsg = "incr backup started back to $incrDate" - . " (backup #$t->{incrBaseBkupNum}) for directory" - . " $t->{shareName}"; - $incrFlag = 1; - } - $bpcdCmd = $conf->{BackupPCdCmd}; - } - - # - # Merge variables into $bpcdCmd - # - my $args = { - host => $t->{host}, - hostIP => $t->{hostIP}, - client => $t->{client}, - shareName => $t->{shareName}, - shareNameSlash => $t->{shareNameSlash}, - restoreDir => $restoreDir, - bpcdPath => $conf->{BackupPCdPath}, - sshPath => $conf->{SshPath}, - topDir => $bpc->TopDir(), - poolDir => $t->{compress} ? $bpc->{CPoolDir} : $bpc->{PoolDir}, - poolCompress => $t->{compress} + 0, - incrFlag => $incrFlag, - }; - $bpcdCmd = $bpc->cmdVarSubstitute($bpcdCmd, $args); - - $t->{bpcdCmd} = $bpcdCmd; - - delete($t->{_errStr}); - - return $logMsg; -} - -sub run -{ - my($t) = @_; - my $bpc = $t->{bpc}; - my $conf = $t->{conf}; - my($remoteSend, $remoteDir, $remoteDirDaemon); - my $error; - my $stats; - - # NO: alarm($conf->{ClientTimeout}); - - # - # Run backupcd command - # - my $str = "Running: " - . $t->{bpc}->execCmd2ShellCmd(@{$t->{bpcdCmd}}) - . "\n"; - $t->{XferLOG}->write(\$str); - - # - # - # - - $bpc->cmdSystemOrEvalLong($t->{bpcdCmd}, - sub { - # write stdout to the XferLOG - my($str) = @_; - $t->{XferLOG}->write(\$str); - }, - 0, # also catch stderr - $t->{pidHandler} - ); - - # - # TODO: generate sensible stats by parsing the output of - # backuppcd. Get error and fail status. - # - if ( !defined($error) && defined($stats) ) { - $t->{xferOK} = 1; - } else { - $t->{xferOK} = 0; - } - $t->{xferErrCnt} = $stats->{errorCnt}; - $t->{byteCnt} = $stats->{TotalFileSize}; - $t->{fileCnt} = $stats->{TotalFileCnt}; - my $str = "Done: $t->{fileCnt} files, $t->{byteCnt} bytes\n"; - $t->{XferLOG}->write(\$str); - - $t->{hostError} = $error if ( defined($error) ); - - if ( $t->{type} eq "restore" ) { - return ( - $t->{fileCnt}, - $t->{byteCnt}, - 0, - 0 - ); - } else { - return ( - 0, - $stats->{ExistFileCnt}, - $stats->{ExistFileSize}, - $stats->{ExistFileCompSize}, - $stats->{TotalFileCnt}, - $stats->{TotalFileSize} - ); - } -} - -1; diff --git a/lib/BackupPC/Xfer/RsyncFileIO.pm b/lib/BackupPC/Xfer/RsyncFileIO.pm index b3e6e92..16f5fbb 100644 --- a/lib/BackupPC/Xfer/RsyncFileIO.pm +++ b/lib/BackupPC/Xfer/RsyncFileIO.pm @@ -12,7 +12,7 @@ # #======================================================================== # -# Version 3.1.0, released 25 Nov 2007. +# Version 3.2.0, released 31 Dec 2008. # # See http://backuppc.sourceforge.net. # @@ -162,6 +162,12 @@ sub csumStart $defBlkSize, $fio->{checksumSeed}, 0, $attr->{compress}, 0, $fio->{protocol_version}); + if ( $err ) { + $fio->log("Can't get rsync digests from $attr->{fullPath}" + . " (err=$err, name=$f->{name})"); + $fio->{stats}{errorCnt}++; + return -1; + } my($isCached, $isInvalid) = $d->isCached; if ( $fio->{logLevel} >= 5 ) { $fio->log("$attr->{fullPath} verify; cached = $isCached," diff --git a/makeDist b/makeDist index 28071a2..39f6f43 100755 --- a/makeDist +++ b/makeDist @@ -14,7 +14,7 @@ # # Often the language files are not up to date, and makeDist # exits after complaining about the lang files being inconsistent. -# Use the -l option to turn off that behavior. +# Use the -nolangCheck option to turn off that behavior. # # AUTHOR # Craig Barratt @@ -37,12 +37,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #======================================================================== -# use strict; use File::Path; use File::Copy; -use Getopt::Std; +use Getopt::Long; +use Data::Dumper; + use lib "./lib"; use BackupPC::Lib; use BackupPC::Config::Meta qw(:all); @@ -53,10 +54,6 @@ die("BackupPC::Lib->new failed\n") umask(0022); -my $Version = "3.2.0"; -my $ReleaseDate = "31 Dec 2008"; -my $DistDir = "dist/BackupPC-$Version"; - my @PerlSrc = qw( bin/BackupPC bin/BackupPC_archive @@ -74,7 +71,6 @@ my @PerlSrc = qw( bin/BackupPC_tarExtract bin/BackupPC_tarCreate bin/BackupPC_tarPCCopy - bin/BackupPC_compressPool bin/BackupPC_zipCreate bin/BackupPC_zcat lib/BackupPC/Attrib.pm @@ -119,7 +115,6 @@ my @PerlSrc = qw( lib/BackupPC/Storage/Text.pm lib/BackupPC/Xfer.pm lib/BackupPC/Xfer/Archive.pm - lib/BackupPC/Xfer/BackupPCd.pm lib/BackupPC/Xfer/Ftp.pm lib/BackupPC/Xfer/Protocol.pm lib/BackupPC/Xfer/Rsync.pm @@ -134,11 +129,33 @@ my @PerlSrc = qw( ); my %opts; -if ( !getopts("l", \%opts) || @ARGV != 0 ) { - print("usage: $0 [-l]\n"); +$opts{langCheck} = 1; +$opts{syntaxCheck} = 1; +if ( !GetOptions( + \%opts, + "l", + "langCheck!", + "syntaxCheck!", + "version=s", + "releasedate=s", + ) || @ARGV != 0 + || !defined($opts{version}) + ) { + print STDERR <{BlackoutHourEnd} = 2; $ConfVars->{BlackoutWeekDays} = 2; $ConfVars->{RsyncLogLevel} = 2; -system("perl -Ilib -c conf/config.pl >& /dev/null") - && die("$0: conf/config.pl contains a syntax error\n"); +if ( $opts{syntaxCheck} ) { + system("perl -Ilib -c conf/config.pl >& /dev/null") + && die("$0: conf/config.pl contains a syntax error (or someone killed me)\n"); +} foreach my $file ( @PerlSrc ) { - system("perl -Ilib -c $file >& /dev/null") - && die("$0: $file contains a syntax error\n"); + if ( $opts{syntaxCheck} ) { + system("perl -Ilib -c $file >& /dev/null") + && die("$0: $file contains a syntax error (or someone killed me)\n"); + } + # + # Skip checking of bundled libraries not explicitly part of + # BackupPC + # + next if ( $file =~ m/lib\/Net\/FTP/ ); $errCnt += CheckConfigParams($file, $ConfVars, 1); } -if ( !$opts{l} ) { +if ( !$opts{langCheck} ) { $errCnt += CheckLangUsage(); $errCnt += CheckLangTags(); }