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.
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
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
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);
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;
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");
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");
#
# Hosts with no errors go after hosts with errors
#
-
return 1 if ( $Status{$a}{error} eq "" && $Status{$b}{error} ne "" );
#
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
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,
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
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,
+++ /dev/null
-#!/bin/perl
-#============================================================= -*-perl-*-
-#
-# BackupPC_compressPool: Compress existing pool
-#
-# DESCRIPTION
-#
-# Usage: BackupPC_compressPool [-t] [-r] <host>
-#
-# 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 <cbarratt@users.sourceforge.net>
-#
-# 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 <<EOF;
-$0: Compress::Zlib is not installed. You need to install it
-before running this script.
-EOF
- exit(1);
-}
-if ( $Compress <= 0 ) {
- print STDERR <<EOF;
-$0: compression is not enabled. \%Conf{CompressLevel} needs
-to be set to a value from 1 to 9. Please edit the config.pl file and
-re-start $0.
-EOF
- exit(1);
-}
-
-my $Errors = 0;
-my $SubDirDone = 0;
-my $SubDirCnt = 0;
-my $SubDirCurr = 0;
-my $FileCnt = 0;
-my $FileOrigSz = 0;
-my $FileCompressSz = 0;
-
-my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort});
-if ( $err eq "" ) {
- print <<EOF;
-BackupPC is running on $Conf{ServerHost}. You need to stop BackupPC
-before you can upgrade the code. Depending upon your installation,
-you could run "/etc/init.d/backuppc stop".
-EOF
- exit(1);
-}
-
-umask($Conf{UmaskMode});
-
-sub cpoolFileName
-{
- my($new) = @_;
- if ( $new !~ m{/(\w/\w/\w)/(\w{32})(_\d+)?$} ) {
- print("Error: Can't parse filename from $new\n");
- $Errors++;
- return;
- }
- my $dir = "$CPoolDir/$1";
- $new = "$dir/$2";
- mkpath($dir, 0, 0777) if ( !-d $dir );
- return $new if ( !-f $new );
- for ( my $i = 0 ; ; $i++ ) {
- return "${new}_$i" if ( !-f "${new}_$i" );
- }
-}
-
-sub doCompress
-{
- my $file = ($File::Find::name =~ /(.*)/ && $1);
- local(*FH, *OUT);
- my(@s) = stat($file);
- my($n, $dataIn, $dataOut, $flush, $copy);
-
- if ( $SigName ) {
- print("Child got signal $SigName; quitting\n");
- reportStats();
- exit(0);
- }
- return if ( !-f $file );
- my $defl = deflateInit(
- -Bufsize => 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 = <FH>;
- $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 <<EOF;
-BackupPC_compressPool: there are $compCnt compressed backups.
-BackupPC_compressPool can only be run when there are no existing
-compressed backups. The following hosts have compressed backups:
-
- + $compHostStr
-
-If you really want to run BackupPC_compressPool you will need to remove
-all the existing compressed backups (and /home/pcbackup/data/cpool).
-Think carefully before you do this. Otherwise, you can just let new
-compressed backups run and the old uncompressed backups and pool will
-steadily expire.
-EOF
- exit(0);
-}
-
-#
-# Next spawn $nChild children that actually do all the work.
-#
-for ( my $i = 0 ; $i < $nChild ; $i++ ) {
- local(*CHILD);
- my $pid;
- if ( !defined($pid = open(CHILD, "-|")) ) {
- print("Can't fork\n");
- next;
- }
- my $nDirs = @Dirs / ($nChild - $i);
- my $nHosts = @Hosts / ($nChild - $i);
- if ( !$pid ) {
- #
- # This is the child.
- # First process each of the hosts (compress per-pc log files etc).
- #
- for ( my $j = 0 ; $j < $nHosts ; $j++ ) {
- compressHostFiles($Hosts[$j]);
- }
- #
- # Count the total number of directories so we can estimate the
- # completion time. We ignore empty directories by reading each
- # directory and making sure it has at least 3 entries (ie, ".",
- # ".." and a file).
- #
- for ( my $j = 0 ; $j < $nDirs ; $j++ ) {
- my $thisDir = $Dirs[$j];
- next if ( !-d "$PoolDir/$thisDir" );
- foreach my $dir ( <$PoolDir/$thisDir/*/*> ) {
- 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);
-}
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
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.
$bpc->cmdSystemOrEval($cmd,
sub {
$XferLOG->write(\$_[0]);
+ print(LOG $bpc->timeStamp, "Output from $cmdType: ", $_[0]);
},
$vars, \%Conf);
}
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
$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;
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);
}
# 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.
# 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} = '';
#
$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)
$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} = <<EOF;
MIME-Version: 1.0
-Content-Type: text/plain; charset="iso-8859-1"
+Content-Type: text/plain; charset="utf-8"
EOF
###########################################################################
FtpBlockSize => 1,
FtpPort => 1,
FtpTimeout => 1,
- BackupPCdPath => 1,
- BackupPCdShareName => 1,
- BackupPCdCmd => 1,
- BackupPCdRestoreCmd => 1,
ArchiveDest => 1,
ArchiveComp => 1,
ArchivePar => 1,
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} ) {
print <<EOF;
BackupPC now supports pool file compression. Since you are upgrading
-BackupPC you probably have existing uncompressed backups. You have
-several choices if you want to turn on compression. You can run
-the script BackupPC_compressPool to convert everything to compressed
-form. Or you can simply turn on compression, so that new backups
-will be compressed. This will increase the pool storage requirement,
-since both uncompressed and compressed copies of files will be stored.
-But eventually the old uncompressed backups will expire, recovering
-the pool storage. Please see the documentation for more details.
+BackupPC you probably have existing uncompressed backups. You could
+turn on compression, so that new backups will be compressed. This
+will increase the pool storage requirement, since both uncompressed
+and compressed copies of files will be stored. But eventually the old
+uncompressed backups will expire, recovering the pool storage. Please
+see the documentation for more details.
If you are not sure what to do, leave the Compression Level at 0,
which disables compression. You can always read the documentation
Compress::Zlib module (see www.cpan.org). For now, leave
the compression level set at 0 to disable compression. If you
want you can install Compress::Zlib and turn compression on.
-Please see the documentation for more details about converting
-old backups to compressed form.
EOF
}
and browsable, but disable all new backups. Alternatively, you can
completely remove the client and all its backups.
-To disable backups for a client there are two special values for
-$Conf{FullPeriod} in that client's per-PC config.pl file:
+To disable backups for a client $Conf{BackupsDisable} can be
+set to two different values in that client's per-PC config.pl file:
=over 4
-=item -1
+=item 1
Don't do any regular backups on this machine. Manually
requested backups (via the CGI interface) will still occur.
-=item -2
+=item 2
Don't do any backups on this machine. Manually requested
backups (via the CGI interface) will be ignored.
If you don't do this, BackupPC will automatically re-read the
hosts file at the next regular wakeup.
-Note that when you remove a client's backups you won't initially recover
-a lot of disk space. That's because the client's files are still in
-the pool. Overnight, when BackupPC_nightly next runs, all the unused
-pool files will be deleted and this will recover the disk space used
-by the client's backups.
+Note that when you remove a client's backups you won't initially
+recover much disk space. That's because the client's files are
+still in the pool. Overnight, when BackupPC_nightly next runs,
+all the unused pool files will be deleted and this will recover
+the disk space used by the client's backups.
=item Copying the pool
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
}
(my $magic, $data) = unpack("N a*", $data);
if ( $magic != $a->{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;
}
#
#========================================================================
#
-# Version 3.1.1, released 22 Dec 2008.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
{name => "UmaskMode"},
{name => "MyPath"},
{name => "DHCPAddressRanges"},
+ {name => "CmdQueueNice"},
{name => "PerlModuleLoad"},
{name => "ServerInitdPath"},
{name => "ServerInitdStartCmd"},
{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"; } },
#
#========================================================================
#
-# Version 3.1.1, released 22 Dec 2008.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
MaxBackupPCNightlyJobs => "integer",
BackupPCNightlyPeriod => "integer",
MaxOldLogFiles => "integer",
+ CmdQueueNice => "integer",
SshPath => {type => "execPath", undefIfEmpty => 1},
NmbLookupPath => {type => "execPath", undefIfEmpty => 1},
FtpTimeout => "integer",
FtpFollowSymlinks => "boolean",
- ######################################################################
- # BackupPCd Configuration
- ######################################################################
- BackupPCdShareName => {
- type => "list",
- child => "string",
- },
- BackupPCdCmd => "string",
- BackupPCdPath => "string",
- BackupPCdRestoreCmd => "string",
-
######################################################################
# Archive Configuration
######################################################################
FtpBlockSize => "boolean",
FtpPort => "boolean",
FtpTimeout => "boolean",
- BackupPCdShareName => "boolean",
- BackupPCdCmd => "boolean",
- BackupPCdPath => "boolean",
- BackupPCdRestoreCmd => "boolean",
ArchiveDest => "boolean",
ArchiveComp => "boolean",
ArchivePar => "boolean",
$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";
$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";
$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";
$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";
$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";
$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";
$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";
$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";
$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 路径/命令";
}
}
#
- # Merge variables into @tarClientCmd
+ # Merge variables into @cmd
#
foreach my $arg ( @$template ) {
#
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;
$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 );
} 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};
+++ /dev/null
-#============================================================= -*-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 <cbarratt@users.sourceforge.net>
-#
-# 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;
#
#========================================================================
#
-# Version 3.1.0, released 25 Nov 2007.
+# Version 3.2.0, released 31 Dec 2008.
#
# See http://backuppc.sourceforge.net.
#
$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,"
#
# 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 <cbarratt@users.sourceforge.net>
# 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);
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
bin/BackupPC_tarExtract
bin/BackupPC_tarCreate
bin/BackupPC_tarPCCopy
- bin/BackupPC_compressPool
bin/BackupPC_zipCreate
bin/BackupPC_zcat
lib/BackupPC/Attrib.pm
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
);
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 <<EOF;
+usage: $0 [--nolangCheck] [--nosyntaxCheck] [--releasedate 'DD MMM YYYY'] --version X.Y.Z
+EOF
exit(1);
}
+my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
+$year += 1900;
+
+my @month_abbr = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+
+my $Version = $opts{version} || "3.2.0";
+my $ReleaseDate = $opts{releasedate} || "$mday $month_abbr[$mon] $year";
+my $DistDir = "dist/BackupPC-$Version";
+
#
# Check config parameters
#
$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();
}