# Version __VERSION__, __RELEASEDATE__
#------------------------------------------------------------------------
-* Added some performance improvements to BackupPC::Xfer::RsyncFileIO
- for the case of small files with cached checksums.
+* Added new script BackupPC_archiveStart that allows command-line
+ starting of archives. Based on script written by Sergey Kovzik,
+ which in turn was based on an earlier version by Holger Parplies.
+
+* Added Simplified Chinese CGI translation from Youlin Feng,
+ plus fixed a couple of cases where utf8 share names were
+ not displayed correctly.
+
+* Added sorting by column feature to host summary table in CGI
+ interface. Implemented by Jeremy Tietsort.
* Added optional support for IO::Dirent which allows inode information
to be extracted from the dirent directory structure. This allows
gain. On other file systems there is no real improvement. This
optimization is turned on automatically if IO::Dirent is installed.
-* Added sorting by column feature to host summary table in CGI
- interface. Implemented by Jeremy Tietsort.
+* Added some performance improvements to BackupPC::Xfer::RsyncFileIO
+ for the case of small files with cached checksums.
-* Added Simplified Chinese CGI translation from Youlin Feng.
+* Added check to BackupPC at startup that $TopDir can support
+ hardlinks. Also added check to BackupPC_dump that a hardlink
+ below $TopDir/pc/HOST can be made to below $TopDir/cpool.
+ Also added the need for a hard-link capable file system to
+ the documentation. Suggested by Nils Breunese.
* Added FreeBSD init.d file provided by Gabriel Rossetti.
provide a file list (without creating the archive).
Requested by Dirk.
+* Made the default charset for BackupPC_zipCreate cp1252, which
+ appears to work correctly with WinZip. Unfortunately there is
+ no clear standard for charset encoding in zip files.
+
+* Added support so that pre-3.0 backups with non-utf8 charsets
+ can be viewed and restored correctly. A new config variable
+ $Conf{ClientCharsetLegacy} specifies the charset used to
+ encode file names in legacy backups. This is only relevant
+ if you are trying to view or restore a backup made with
+ BackupPC 2.x and some of the file names have non-ascii
+ characters.
+
+* Added setting of the environment variable BPC_REQUSER to
+ the requesting user name in BackupPC prior to fork(), so
+ each child process inherits the value. Submitted by
+ Holger Parplies.
+
+* Fixed bug in rsync incrementals that happens on particular
+ file names when a file being backed up fails in both rsync
+ phases. Reported by Dan Smisko.
+
* Fixed single-restore file name charsets for IE, reported by
Francis Lessard.
* Fixed makeDist so that the --config-dir option to configure.pl
works correctly. Reported by Randy Barlow, Tony Shadwick and others.
+* Removed ConfDir from config editor (since it is hardcoded in
+ lib/BackupPC/Lib.pm). Also made TopDir and LogDir only visible
+ if useFHS (for non-FHS they are hardcoded in lib/BackupPC/Lib.pm).
+
* Applied patch from Holger Parplies that fixes cleanup of early abort
in BackupPC_dump.
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use lib "/usr/local/BackupPC/lib";
use BackupPC::Lib;
use BackupPC::FileZIO;
-use Encode;
+use Encode qw/decode_utf8/;
use File::Path;
use Data::Dumper;
umask($Conf{UmaskMode});
#
- # Check for another running process, check that PASSWD is set and
- # verify executables are configured correctly.
+ # Check for another running process, verify executables are configured
+ # correctly and make sure $TopDir is on a file system that supports
+ # hardlinks.
#
if ( $Info{pid} ne "" && kill(0, $Info{pid}) ) {
print(STDERR $bpc->timeStamp,
"Another BackupPC is running (pid $Info{pid}); quitting...\n");
exit(1);
}
+
foreach my $progName ( qw(SmbClientPath NmbLookupPath PingPath DfPath
SendmailPath SshPath) ) {
next if ( $Conf{$progName} eq "" || -x $Conf{$progName} );
exit(1);
}
+ if ( !$bpc->HardlinkTest("$TopDir/pc", "$TopDir/cpool") ) {
+ print(STDERR $bpc->timeStamp, "Can't create a test hardlink between a file"
+ . " in $TopDir/pc and $TopDir/cpool. Either these are different"
+ . " file systems, or this file system doesn't support hardlinks,"
+ . " or these directories don't exist, or there is a permissions"
+ . " problem, or the file system is out of inodes or full. Use"
+ . " df, df -i, and ls -ld to check each of these possibilities."
+ . " Quitting...\n");
+ exit(1);
+ }
+
if ( $opts{d} ) {
#
# daemonize by forking; more robust method per:
}
if ( !$pid ) {
setpgrp 0,0;
+ $ENV{BPC_REQUSER} = $req->{user};
exec(@$cmd);
print(LOG $bpc->timeStamp, "can't exec @$cmd for $host\n");
exit(0);
[ \%Info, \%Status],
[qw(*Info *Status)]);
$dump->Indent(1);
- if ( open(STATUS, ">", "$LogDir/status.pl") ) {
- print(STATUS $dump->Dump);
- close(STATUS);
- }
+ $bpc->{storage}->TextFileWrite("$LogDir/status.pl", $dump->Dump);
}
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
# as a starting point for an incremental.
#
@Backups = $bpc->BackupInfoRead($client);
-## @Backups = sort( { $a->{startTime} <=> $b->{startTime} }, @Backups);
for ( my $i = 0 ; $i < @Backups ; $i++ ) {
$needLink = 1 if ( $Backups[$i]{nFilesNew} eq ""
|| -f "$Dir/NewFileList.$Backups[$i]{num}" );
NothingToDo($needLink);
}
+if ( !$bpc->HardlinkTest($Dir, "$TopDir/cpool") ) {
+ print(LOG $bpc->timeStamp, "Can't create a test hardlink between a file"
+ . " in $Dir and $TopDir/cpool. Either these are different"
+ . " file systems, or this file system doesn't support hardlinks,"
+ . " or these directories don't exist, or there is a permissions"
+ . " problem, or the file system is out of inodes or full. Use"
+ . " df, df -i, and ls -ld to check each of these possibilities."
+ . " Quitting...\n");
+ print("test hardlink between $Dir and $TopDir/cpool failed\n");
+ print("link $clientURI\n") if ( $needLink );
+ exit(1);
+}
+
#
# Check if $host is alive
#
$stat{xferOK} = 0 if ( $Abort );
+#
+# If there is no "new" directory then the backup is bad
+#
+if ( $stat{xferOK} && !-d "$Dir/new" ) {
+ $stat{hostError} = "No backup directory $Dir/new"
+ if ( $stat{hostError} eq "" );
+ $stat{xferOK} = 0;
+}
+
#
# Do one last check to make sure it is still the machine we expect.
#
# (the new backup might also be a partial, but that's ok).
#
BackupPartialRemove($client, \@Backups);
+ $needLink = 1 if ( -f "$Dir/NewFileList" );
#
# Number the new backup
if ( !rename("$Dir/new", "$Dir/$num") ) {
print(LOG $bpc->timeStamp, "Rename $Dir/new -> $Dir/$num failed\n");
$stat{xferOK} = 0;
+ return;
}
- $needLink = 1 if ( -f "$Dir/NewFileList" );
#
# Add the new backup information to the backup file
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
-w writeBufSz write buffer size (default 1048576 = 1MB)
-e charset charset for encoding file names (default: value of
\$Conf{ClientCharset} when backup was done)
+ -l just print a file listing; don't generate an archive
+ -L just print a detailed file listing; don't generate an archive
EOF
exit(1);
}
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
# -r pathRemove path prefix that will be replaced with pathAdd
# -p pathAdd new path prefix
# -c level compression level (default is 0, no compression)
-# -e charset charset for encoding file names (default: value of
-# $Conf{ClientCharset} when backup was done)
+# -e charset charset for encoding file names (default: cp1252)
#
# The -h, -n and -s options specify which dump is used to generate
# the zip archive. The -r and -p options can be used to relocate
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
-r pathRemove path prefix that will be replaced with pathAdd
-p pathAdd new path prefix
-c level compression level (default is 0, no compression)
- -e charset charset for encoding file names (default: value of
- \$Conf{ClientCharset} when backup was done)
+ -e charset charset for encoding file names (default: cp1252)
EOF
exit(1);
}
exit(1);
}
-my $Charset = $Backups[$i]{charset};
+my $Charset = "cp1252";
$Charset = $opts{e} if ( $opts{e} ne "" );
my $PathRemove = $1 if ( $opts{r} =~ /(.+)/ );
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
$Conf{ClientCharset} = '';
+#
+# Prior to 3.x no charset conversion was done by BackupPC. Backups were
+# stored in what ever charset the XferMethod provided - typically utf8
+# for smbclient and the client's locale settings for rsync and tar (eg:
+# cp1252 for rsync on WinXX and perhaps iso-8859-1 with rsync on linux).
+# This setting tells BackupPC the charset that was used to store file
+# names in old backups taken with BackupPC 2.x, so that non-ascii file
+# names in old backups can be viewed and restored.
+#
+$Conf{ClientCharsetLegacy} = 'iso-8859-1';
+
#
# Name of the host share that is backed up when using SMB. This can be a
# string or an array of strings if there are multiple shares per host.
BlackoutPeriods => 1,
BackupZeroFilesIsFatal => 1,
ClientCharset => 1,
+ ClientCharsetLegacy => 1,
XferMethod => 1,
XferLogLevel => 1,
SmbShareName => 1,
BackupPC's CGI script needs to display various GIF images that
should be stored where Apache can serve them. They should be
-placed somewher under Apache's DocumentRoot. BackupPC also
+placed somewhere under Apache's DocumentRoot. BackupPC also
needs to know the URL to access these images. Example:
Apache image directory: /usr/local/apache/htdocs/BackupPC
=back
+=head2 What type of storage space do I need?
+
+BackupPC uses hardlinks to pool files common to different backups.
+Therefore BackupPC's data store (__TOPDIR__) must point to a single
+file system that supports hardlinks. You cannot split this file
+system with multiple mount points or using symbolic links to point a
+sub-directory to a different file system (it is ok to use a single
+symbolic link at the top-level directory (__TOPDIR__) to point the
+entire data store somewhere else). You can of course use any kind of
+RAID system or logical volume manager that combines the capacity of
+multiple disks into a single, larger, file system. Such approaches
+have the advantage that the file system can be expanded without having
+to copy it.
+
+Any standard linux or unix file system supports hardlinks. NFS mounted
+file systems work too (provided the underlying file system supports
+hardlinks). But windows based FAT and NTFS file systems will not work.
+
+Starting with BackupPC 3.1.0, run-time checks are done at startup and
+at the start of each backup to ensure that the file system can support
+hardlinks, since this is a common area of configuration problems.
+
=head2 How much disk space do I need?
Here's one real example for an environment that is backing up 65 laptops
The usage is:
- BackupPC_tarCreate [-t] [-h host] [-n dumpNum] [-s shareName]
- [-r pathRemove] [-p pathAdd] [-b BLOCKS] [-w writeBufSz]
- files/directories...
+ BackupPC_tarCreate [options] files/directories...
+ Required options:
+ -h host host from which the tar archive is created
+ -n dumpNum dump number from which the tar archive is created
+ A negative number means relative to the end (eg -1
+ means the most recent dump, -2 2nd most recent etc).
+ -s shareName share name from which the tar archive is created
+
+ Other options:
+ -t print summary totals
+ -r pathRemove path prefix that will be replaced with pathAdd
+ -p pathAdd new path prefix
+ -b BLOCKS BLOCKS x 512 bytes per record (default 20; same as tar)
+ -w writeBufSz write buffer size (default 1048576 = 1MB)
+ -e charset charset for encoding file names (default: value of
+ $Conf{ClientCharset} when backup was done)
+ -l just print a file listing; don't generate an archive
+ -L just print a detailed file listing; don't generate an archive
The command-line files and directories are relative to the specified
shareName. The tar file is written to stdout.
-The required options are:
-
-=over 4
-
-=item -h host
-
-host from which the tar archive is created
-
-=item -n dumpNum
-
-dump number from which the tar archive is created
-
-=item -s shareName
-
-share name from which the tar archive is created
-
-=back
-
-Other options are:
-
-=over 4
-
-=item -t
-
-print summary totals
-
-=item -r pathRemove
-
-path prefix that will be replaced with pathAdd
-
-=item -p pathAdd
-
-new path prefix
-
-=item -b BLOCKS
-
-the tar block size, default is 20, meaning tar writes data in 20 * 512
-bytes chunks.
-
-=item -w writeBufSz
-
-write buffer size, default 1048576 (1MB). You can increase this if
-you are trying to stream to a fast tape device.
-
-=back
-
The -h, -n and -s options specify which dump is used to generate
the tar archive. The -r and -p options can be used to relocate
the paths in the tar archive so extracted files can be placed
The usage is:
- BackupPC_zipCreate [-t] [-h host] [-n dumpNum] [-s shareName]
- [-r pathRemove] [-p pathAdd] [-c compressionLevel]
- files/directories...
+ BackupPC_zipCreate [options] files/directories...
+ Required options:
+ -h host host from which the zip archive is created
+ -n dumpNum dump number from which the tar archive is created
+ A negative number means relative to the end (eg -1
+ means the most recent dump, -2 2nd most recent etc).
+ -s shareName share name from which the zip archive is created
+
+ Other options:
+ -t print summary totals
+ -r pathRemove path prefix that will be replaced with pathAdd
+ -p pathAdd new path prefix
+ -c level compression level (default is 0, no compression)
+ -e charset charset for encoding file names (default: cp1252)
The command-line files and directories are relative to the specified
-shareName. The zip file is written to stdout.
-
-The required options are:
-
-=over 4
-
-=item -h host
-
-host from which the zip archive is created
-
-=item -n dumpNum
-
-dump number from which the zip archive is created
-
-=item -s shareName
-
-share name from which the zip archive is created
-
-=back
-
-Other options are:
-
-=over 4
-
-=item -t
-
-print summary totals
-
-=item -r pathRemove
-
-path prefix that will be replaced with pathAdd
-
-=item -p pathAdd
-
-new path prefix
-
-=item -c level
-
-compression level (default is 0, no compression)
-
-=back
-
-The -h, -n and -s options specify which dump is used to generate
-the zip archive. The -r and -p options can be used to relocate
-the paths in the zip archive so extracted files can be placed
-in a location different from their original location.
+shareName. The zip file is written to stdout. The -h, -n and -s
+options specify which dump is used to generate the zip archive. The
+-r and -p options can be used to relocate the paths in the zip archive
+so extracted files can be placed in a location different from their
+original location.
=back
Press the "Start the Archive" to start archiving the selected hosts with the
parameters displayed.
+=head2 Starting an Archive from the command line
+
+The script BackupPC_archiveStart can be used to start an archive from
+the command line (or cron etc). The usage is:
+
+ BackupPC_archiveStart archiveHost userName hosts...
+
+This creates an archive of the most recent backup of each of
+the specified hosts. The first two arguments are the archive
+host and the user name making the request.
+
=head1 Other CGI Functions
=head2 Configuration and Host Editor
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use Carp;
use File::Path;
use BackupPC::FileZIO;
-use Encode;
+use Encode qw/from_to/;
require Exporter;
use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS );
}
}
(my $fileName, $data) = unpack("a$len a*", $data);
+
from_to($fileName, $a->{charsetLegacy}, "utf8")
if ( $a->{charsetLegacy} ne "" );
my $nFldsW = @FldsUnixW;
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
package BackupPC::CGI::Browse;
use strict;
-use Encode;
+use Encode qw/decode_utf8/;
use BackupPC::CGI::Lib qw(:all);
use BackupPC::View;
use BackupPC::Attrib qw(:all);
}
$filledBackup .= eval("qq{$Lang->{Visit_this_directory_in_backup}}");
}
- $dir = decode_utf8($dir);
+ $dir = decode_utf8($dir);
+ $share = decode_utf8($share);
my $content = eval("qq{$Lang->{Backup_browse_for__host}}");
Header(eval("qq{$Lang->{Browse_backup__num_for__host}}"), $content);
Trailer();
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
{name => "Bzip2Path"},
{text => "CfgEdit_Title_Install_Paths"},
- {name => "TopDir"},
- {name => "ConfDir"},
- {name => "LogDir"},
+ #
+ # Can only edit TopDir and LogDir if we are in FHS mode.
+ # Otherwise they are hardcoded in lib/BackupPC/Lib.pm.
+ #
+ {name => "TopDir",
+ visible => sub { return $_[1]->useFHS(); } },
+ {name => "LogDir",
+ visible => sub { return $_[1]->useFHS(); } },
{name => "CgiDir"},
- {name => "InstallDir"},
+ #
+ # Cannot edit ConfDir or InstallDir, since the real value is hardcoded in
+ # lib/BackupPC/Lib.pm.
+ # {name => "ConfDir"},
+ # {name => "InstallDir"},
+ #
],
},
email => {
{name => "XferMethod", onchangeSubmit => 1},
{name => "XferLogLevel"},
{name => "ClientCharset"},
+ {name => "ClientCharsetLegacy"},
{text => "CfgEdit_Title_Smb_Settings",
visible => sub { return $_[0]->{XferMethod} eq "smb"; } },
next if ( $disabled || $menuDisable{$menu}{top} );
if ( ref($paramInfo->{visible}) eq "CODE"
- && !&{$paramInfo->{visible}}($newConf) ) {
+ && !&{$paramInfo->{visible}}($newConf, $bpc) ) {
next;
}
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use BackupPC::CGI::Lib qw(:all);
use Data::Dumper;
use File::Path;
-use Encode;
+use Encode qw/decode_utf8/;
sub action
{
EOF
}
$hiddenStr .= "<input type=\"hidden\" name=\"fcbMax\" value=\"$In{fcbMax}\">\n";
- $hiddenStr .= "<input type=\"hidden\" name=\"share\" value=\"${EscHTML($share)}\">\n";
+ $hiddenStr .= "<input type=\"hidden\" name=\"share\" value=\"${EscHTML(decode_utf8($share))}\">\n";
$badFileCnt++ if ( $In{pathHdr} =~ m{(^|/)\.\.(/|$)} );
$badFileCnt++ if ( $In{num} =~ m{(^|/)\.\.(/|$)} );
if ( @fileList == 0 ) {
# Tell the user what options they have
#
$pathHdr = decode_utf8($pathHdr);
- $content .= eval("qq{$Lang->{Restore_Options_for__host2}}");
+ $share = decode_utf8($share);
+ $content = eval("qq{$Lang->{Restore_Options_for__host2}}");
if ( @hosts == 1 ) {
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use BackupPC::FileZIO;
use BackupPC::Attrib qw(:all);
use BackupPC::View;
-use Encode qw/from_to/;
+use Encode qw/from_to decode_utf8/;
sub action
{
ErrorExit("Can't restore bad file ${EscHTML($dir)} ($num, $share)");
}
my $f = BackupPC::FileZIO->open($a->{fullPath}, 0, $a->{compress});
+ if ( !defined($f) ) {
+ my $fullPath = decode_utf8($a->{fullPath});
+ ErrorExit("Unable to open file ${EscHTML($fullPath)} ($num, $share)");
+ }
my $data;
if ( !$skipHardLink && $a->{type} == BPC_FTYPE_HARDLINK ) {
#
print "Content-Type: $contentType\n";
print "Content-Transfer-Encoding: binary\n";
- if ( $ENV{HTTP_USER_AGENT} =~ /\bmsie\b/i ) {
+ if ( $ENV{HTTP_USER_AGENT} =~ /\bmsie\b/i
+ && $ENV{HTTP_USER_AGENT} !~ /\bopera\b/i ) {
#
# Convert to cp1252 for MS IE. TODO: find a way to get IE
# to accept UTF8 encoding. Firefox accepts inline encoding
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use strict;
use BackupPC::CGI::Lib qw(:all);
-use Encode;
+use Encode qw/decode_utf8/;
sub action
{
<tr><td>$RestoreReq{hostSrc}:/$strippedShareSrc$f</td><td>$RestoreReq{hostDest}:/$strippedShareDest$targetFile</td></tr>
EOF
}
+ $RestoreReq{shareSrc} = decode_utf8($RestoreReq{shareSrc});
+ $RestoreReq{shareDest} = decode_utf8($RestoreReq{shareDest});
my $content = eval("qq{$Lang->{Restore___num_details_for__host2}}");
Header(eval("qq{$Lang->{Restore___num_details_for__host}}"),$content);
Trailer();
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
XferLogLevel => "integer",
ClientCharset => "string",
+ ClientCharsetLegacy => "string",
SmbShareName => {
type => "list",
XferMethod => "boolean",
XferLogLevel => "boolean",
ClientCharset => "boolean",
+ ClientCharsetLegacy => "boolean",
SmbShareName => "boolean",
SmbShareUserName => "boolean",
SmbSharePasswd => "boolean",
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
-#!/usr/bin/perl
+#!/bin/perl
#my %lang;
#use strict;
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use Cwd;
use Digest::MD5;
use Config;
-use Encode;
+use Encode qw/from_to encode_utf8/;
use vars qw( $IODirentOk );
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
useFHS => $useFHS,
TopDir => $topDir,
InstallDir => $installDir,
- ConfDir => $confDir eq "" ? '/etc/BackupPC' : $confDir,
+ ConfDir => $confDir eq "" ? '/tera0/backup/BackupPC/conf' : $confDir,
LogDir => '/var/log/BackupPC',
};
} else {
my $bpc = bless {
%$paths,
- Version => '3.0.0',
+ Version => '3.1.0beta0',
}, $class;
$bpc->{storage} = BackupPC::Storage->new($paths);
}
}
+#
+# Tests if we can create a hardlink from a file in directory
+# $newDir to a file in directory $targetDir. A temporary
+# file in $targetDir is created and an attempt to create a
+# hardlink of the same name in $newDir is made. The temporary
+# files are removed.
+#
+# Like link(), returns true on success and false on failure.
+#
+sub HardlinkTest
+{
+ my($bpc, $targetDir, $newDir) = @_;
+
+ my($targetFile, $newFile, $fd);
+ for ( my $i = 0 ; ; $i++ ) {
+ $targetFile = "$targetDir/.TestFileLink.$$.$i";
+ $newFile = "$newDir/.TestFileLink.$$.$i";
+ last if ( !-e $targetFile && !-e $newFile );
+ }
+ return 0 if ( !open($fd, ">", $targetFile) );
+ close($fd);
+ my $ret = link($targetFile, $newFile);
+ unlink($targetFile);
+ unlink($newFile);
+ return $ret;
+}
+
sub CheckHostAlive
{
my($bpc, $host) = @_;
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
}
close(LOCK);
#
- # Default the level and version fields if not present
+ # Default the version field. Prior to 3.0.0 the xferMethod
+ # field is empty, so we use that to figure out the version.
#
for ( my $i = 0 ; $i < @Backups ; $i++ ) {
- if ( defined($Backups[$i]{level}) ) {
- if ( !defined($Backups[$i]{version}) ) {
- $Backups[$i]{version} = "3.0.0";
- }
- } else {
- $Backups[$i]{level} = $Backups[$i]{type} eq "incr" ? 1 : 0;
+ next if ( $Backups[$i]{version} ne "" );
+ if ( $Backups[$i]{xferMethod} eq "" ) {
$Backups[$i]{version} = "2.1.2";
+ } else {
+ $Backups[$i]{version} = "3.0.0";
}
}
return @Backups;
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
use BackupPC::Attrib qw(:all);
use BackupPC::FileZIO;
use Data::Dumper;
+use Encode qw/from_to/;
sub new
{
push(@{$m->{mergeNums}}, $backupNum);
my $mangle = $m->{backups}[$i]{mangle};
my $compress = $m->{backups}[$i]{compress};
- my $path = "$m->{topDir}/pc/$m->{host}/$backupNum/";
+ my $path = "$m->{topDir}/pc/$m->{host}/$backupNum/";
+ my $legacyCharset = $m->{backups}[$i]{version} < 3.0;
my $sharePathM;
if ( $mangle ) {
$sharePathM = $m->{bpc}->fileNameEltMangle($share)
$sharePathM = $share . $dir;
}
$path .= $sharePathM;
- #print(STDERR "Opening $path (share=$share)\n");
+ #print(STDERR "Opening $path (share=$share, mangle=$mangle)\n");
+
+ my $dirOpts = { %{$m->{dirOpts} || {} } };
+ my $attribOpts = { compress => $compress };
+ if ( $legacyCharset ) {
+ $dirOpts->{charsetLegacy}
+ = $attribOpts->{charsetLegacy}
+ = $m->{bpc}->{Conf}{ClientCharsetLegacy} || "iso-8859-1";
+ }
- my $dirInfo = $m->{bpc}->dirRead($path, $m->{dirOpts});
+ my $dirInfo = $m->{bpc}->dirRead($path, $dirOpts);
if ( !defined($dirInfo) ) {
if ( $i == $m->{idx} ) {
#
}
my $attr;
if ( $mangle ) {
- $attr = BackupPC::Attrib->new({ compress => $compress });
+ $attr = BackupPC::Attrib->new($attribOpts);
if ( !$attr->read($path) ) {
- $m->{error} = "Can't read attribute file in $path";
+ $m->{error} = "Can't read attribute file in $path: " . $attr->errStr();
$attr = undef;
}
}
|| $file eq "."
|| $file eq "backupInfo"
|| $mangle && $file eq "attrib" );
+
if ( defined($attr) && defined(my $a = $attr->get($fileUM)) ) {
$m->{files}{$fileUM} = $a;
#
# is on. We have to stat the file and read compressed files
# to determine their size.
#
- my @s = stat("$path/$file");
+ my $realPath = "$path/$file";
+
+ from_to($realPath, "utf8", $attribOpts->{charsetLegacy})
+ if ( $attribOpts->{charsetLegacy} ne "" );
+
+ my @s = stat($realPath);
next if ( $i < $m->{idx} && -d _ );
$m->{files}{$fileUM} = {
type => -d _ ? BPC_FTYPE_DIR : BPC_FTYPE_FILE,
#
# Compute the correct size by reading the whole file
#
- my $f = BackupPC::FileZIO->open("$path/$file",
+ my $f = BackupPC::FileZIO->open($realPath,
0, $compress);
if ( !defined($f) ) {
- $m->{error} = "Can't open $path/$file";
+ $m->{error} = "Can't open $realPath";
} else {
my($data, $size);
while ( $f->read(\$data, 65636 * 8) > 0 ) {
($m->{files}{$fileUM}{sharePathM} = "$sharePathM/$file")
=~ s{//+}{/}g;
($m->{files}{$fileUM}{fullPath} = "$path/$file") =~ s{//+}{/}g;
+ from_to($m->{files}{$fileUM}{fullPath}, "utf8", $attribOpts->{charsetLegacy})
+ if ( $attribOpts->{charsetLegacy} ne "" );
$m->{files}{$fileUM}{backupNum} = $backupNum;
$m->{files}{$fileUM}{compress} = $compress;
$m->{files}{$fileUM}{nlink} = $entry->{nlink}
$m->{files}{$fileUM}{relPath} = "$dir/$fileUM";
$m->{files}{$fileUM}{sharePathM} = "$sharePathM/$file";
$m->{files}{$fileUM}{fullPath} = "$path/$file";
+ from_to($m->{files}{$fileUM}{fullPath}, "utf8", $attribOpts->{charsetLegacy})
+ if ( $attribOpts->{charsetLegacy} ne "" );
$m->{files}{$fileUM}{backupNum} = $backupNum;
$m->{files}{$fileUM}{compress} = $compress;
$m->{files}{$fileUM}{nlink} = 0;
my $mangle = $m->{backups}[$i]{mangle};
my $compress = $m->{backups}[$i]{compress};
my $path = "$m->{topDir}/pc/$m->{host}/$backupNum/";
+ my $legacyCharset = $m->{backups}[$i]{version} < 3.0;
my $sharePathM;
if ( $mangle ) {
$sharePathM = $m->{bpc}->fileNameEltMangle($share)
$path .= $sharePathM;
#print(STDERR "Opening $path (share=$share)\n");
- my $dirInfo = $m->{bpc}->dirRead($path, $m->{dirOpts});
+ my $dirOpts = { %{$m->{dirOpts} || {} } };
+ my $attribOpts = { compress => $compress };
+ if ( $legacyCharset ) {
+ $dirOpts->{charsetLegacy}
+ = $attribOpts->{charsetLegacy}
+ = $m->{bpc}->{Conf}{ClientCharsetLegacy} || "iso-8859-1";
+ }
+
+ my $dirInfo = $m->{bpc}->dirRead($path, $dirOpts);
if ( !defined($dirInfo) ) {
#
# Oops, directory doesn't exist.
}
my $attr;
if ( $mangle ) {
- $attr = BackupPC::Attrib->new({ compress => $compress });
+ $attr = BackupPC::Attrib->new($attribOpts);
if ( !$attr->read($path) ) {
$m->{error} = "Can't read attribute file in $path";
$attr = undef;
|| $file eq "."
|| $mangle && $file eq "attrib"
|| defined($files->{$fileUM}[$i]) );
- my @s = stat("$path/$file");
+
+ my $realPath = "$path/$file";
+ from_to($realPath, "utf8", $attribOpts->{charsetLegacy})
+ if ( $attribOpts->{charsetLegacy} ne "" );
+ my @s = stat($realPath);
if ( defined($attr) && defined(my $a = $attr->get($fileUM)) ) {
$files->{$fileUM}[$i] = $a;
$attr->set($fileUM, undef);
#
# Compute the correct size by reading the whole file
#
- my $f = BackupPC::FileZIO->open("$path/$file",
+ my $f = BackupPC::FileZIO->open("$realPath",
0, $compress);
if ( !defined($f) ) {
$m->{error} = "Can't open $path/$file";
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
#
#========================================================================
#
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.1.0beta0, released 3 Sep 2007.
#
# See http://backuppc.sourceforge.net.
#
umask(0022);
-my $Version = "3.1.0";
-my $ReleaseDate = "15 Apr 2007";
+my $Version = "3.1.0beta0";
+my $ReleaseDate = "3 Sep 2007";
my $DistDir = "dist/BackupPC-$Version";
my @PerlSrc = qw(
$ConfVars->{ConfDir} = 2;
$ConfVars->{InstallDir} = 2;
$ConfVars->{CgiImageDir} = 2;
+$ConfVars->{ClientCharsetLegacy} = 2; # actually used
#
# These config parameters are used in the code to be backward compatible,