From: cbarratt Date: Mon, 3 Sep 2007 17:19:53 +0000 (+0000) Subject: Changes for 3.1.0beta0. X-Git-Tag: v3_1_0beta0~2 X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=fadae1eaa5482a441bc8e8aa829a063ee6a5f0c0 Changes for 3.1.0beta0. * 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 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. * 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. * 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). --- diff --git a/ChangeLog b/ChangeLog index f184c6f..742d05b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,8 +21,16 @@ # 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 @@ -31,10 +39,14 @@ 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. @@ -42,12 +54,37 @@ 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. diff --git a/bin/BackupPC b/bin/BackupPC index 2053aa5..ae8e918 100755 --- a/bin/BackupPC +++ b/bin/BackupPC @@ -47,7 +47,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -59,7 +59,7 @@ use vars qw(%Status %Info $Hosts); 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; @@ -248,14 +248,16 @@ sub Main_Initialize 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} ); @@ -265,6 +267,17 @@ sub Main_Initialize 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: @@ -522,6 +535,7 @@ sub Main_TryToRun_CmdQueue } 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); @@ -1576,10 +1590,7 @@ sub StatusWrite [ \%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); } # diff --git a/bin/BackupPC_archive b/bin/BackupPC_archive index a2265c4..246c12a 100644 --- a/bin/BackupPC_archive +++ b/bin/BackupPC_archive @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_archiveHost b/bin/BackupPC_archiveHost index 8e6c483..eefa236 100755 --- a/bin/BackupPC_archiveHost +++ b/bin/BackupPC_archiveHost @@ -38,7 +38,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_archiveStart b/bin/BackupPC_archiveStart index 54ec76a..09ed23e 100755 --- a/bin/BackupPC_archiveStart +++ b/bin/BackupPC_archiveStart @@ -35,7 +35,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_attribPrint b/bin/BackupPC_attribPrint index 53c2f72..8fcf821 100755 --- a/bin/BackupPC_attribPrint +++ b/bin/BackupPC_attribPrint @@ -31,7 +31,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_compressPool b/bin/BackupPC_compressPool index e11a611..dddccce 100755 --- a/bin/BackupPC_compressPool +++ b/bin/BackupPC_compressPool @@ -49,7 +49,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index d0925f0..8da28c3 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -70,7 +70,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -388,7 +388,6 @@ my(@lastIdxByLevel, $incrCntSinceFull); # 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}" ); @@ -457,6 +456,19 @@ if ( @Backups == 0 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 # @@ -908,6 +920,15 @@ if ( $type eq "full" && $stat{hostError} eq "" $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. # @@ -1379,6 +1400,7 @@ sub BackupSave # (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 @@ -1391,8 +1413,8 @@ sub BackupSave 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 diff --git a/bin/BackupPC_fixupBackupSummary b/bin/BackupPC_fixupBackupSummary index 2b308b4..67210d7 100755 --- a/bin/BackupPC_fixupBackupSummary +++ b/bin/BackupPC_fixupBackupSummary @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_link b/bin/BackupPC_link index d05b61c..2528c17 100755 --- a/bin/BackupPC_link +++ b/bin/BackupPC_link @@ -39,7 +39,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_nightly b/bin/BackupPC_nightly index 22782d1..a31332c 100755 --- a/bin/BackupPC_nightly +++ b/bin/BackupPC_nightly @@ -55,7 +55,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_restore b/bin/BackupPC_restore index 81eefaa..046390d 100755 --- a/bin/BackupPC_restore +++ b/bin/BackupPC_restore @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_sendEmail b/bin/BackupPC_sendEmail index d826893..4b0b055 100755 --- a/bin/BackupPC_sendEmail +++ b/bin/BackupPC_sendEmail @@ -31,7 +31,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_serverMesg b/bin/BackupPC_serverMesg index 4fe7c20..7b92139 100755 --- a/bin/BackupPC_serverMesg +++ b/bin/BackupPC_serverMesg @@ -43,7 +43,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_tarCreate b/bin/BackupPC_tarCreate index 5548672..662a3be 100755 --- a/bin/BackupPC_tarCreate +++ b/bin/BackupPC_tarCreate @@ -55,7 +55,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -94,6 +94,8 @@ usage: $0 [options] files/directories... -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); } diff --git a/bin/BackupPC_tarExtract b/bin/BackupPC_tarExtract index 4043bf0..5f14508 100755 --- a/bin/BackupPC_tarExtract +++ b/bin/BackupPC_tarExtract @@ -27,7 +27,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_tarPCCopy b/bin/BackupPC_tarPCCopy index b5194d3..62f0a94 100755 --- a/bin/BackupPC_tarPCCopy +++ b/bin/BackupPC_tarPCCopy @@ -38,7 +38,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_trashClean b/bin/BackupPC_trashClean index c3c2d0c..6d144b3 100755 --- a/bin/BackupPC_trashClean +++ b/bin/BackupPC_trashClean @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_zcat b/bin/BackupPC_zcat index 13c5da1..a08f3ed 100755 --- a/bin/BackupPC_zcat +++ b/bin/BackupPC_zcat @@ -32,7 +32,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/bin/BackupPC_zipCreate b/bin/BackupPC_zipCreate index cb13b2f..f42690f 100755 --- a/bin/BackupPC_zipCreate +++ b/bin/BackupPC_zipCreate @@ -21,8 +21,7 @@ # -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 @@ -52,7 +51,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -94,8 +93,7 @@ usage: $0 [options] files/directories... -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); } @@ -137,7 +135,7 @@ if ( $i >= @Backups ) { exit(1); } -my $Charset = $Backups[$i]{charset}; +my $Charset = "cp1252"; $Charset = $opts{e} if ( $opts{e} ne "" ); my $PathRemove = $1 if ( $opts{r} =~ /(.+)/ ); diff --git a/cgi-bin/BackupPC_Admin b/cgi-bin/BackupPC_Admin index 79e66fe..a53f805 100755 --- a/cgi-bin/BackupPC_Admin +++ b/cgi-bin/BackupPC_Admin @@ -39,7 +39,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/conf/config.pl b/conf/config.pl index fd78dfc..461e3f8 100644 --- a/conf/config.pl +++ b/conf/config.pl @@ -868,6 +868,17 @@ $Conf{XferLogLevel} = 1; # $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. @@ -2034,6 +2045,7 @@ $Conf{CgiUserConfigEdit} = { BlackoutPeriods => 1, BackupZeroFilesIsFatal => 1, ClientCharset => 1, + ClientCharsetLegacy => 1, XferMethod => 1, XferLogLevel => 1, SmbShareName => 1, diff --git a/configure.pl b/configure.pl index 0e5a0df..e604ac1 100755 --- a/configure.pl +++ b/configure.pl @@ -474,7 +474,7 @@ if ( $Conf{CgiDir} ne "" ) { 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 diff --git a/doc-src/BackupPC.pod b/doc-src/BackupPC.pod index 60f5b01..457f682 100644 --- a/doc-src/BackupPC.pod +++ b/doc-src/BackupPC.pod @@ -415,6 +415,28 @@ with mod_perl support. =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 @@ -1618,59 +1640,28 @@ incremental or full backup. 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 @@ -1685,57 +1676,27 @@ incremental or full backup. 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 @@ -1794,6 +1755,17 @@ The next screen allows you to adjust the parameters for this archive run. 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 diff --git a/lib/BackupPC/Attrib.pm b/lib/BackupPC/Attrib.pm index 2a76244..1c0e2a9 100644 --- a/lib/BackupPC/Attrib.pm +++ b/lib/BackupPC/Attrib.pm @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -43,7 +43,7 @@ use strict; 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 ); @@ -243,6 +243,7 @@ sub read } } (my $fileName, $data) = unpack("a$len a*", $data); + from_to($fileName, $a->{charsetLegacy}, "utf8") if ( $a->{charsetLegacy} ne "" ); my $nFldsW = @FldsUnixW; diff --git a/lib/BackupPC/CGI/AdminOptions.pm b/lib/BackupPC/CGI/AdminOptions.pm index e143a60..8eb2fbf 100644 --- a/lib/BackupPC/CGI/AdminOptions.pm +++ b/lib/BackupPC/CGI/AdminOptions.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Archive.pm b/lib/BackupPC/CGI/Archive.pm index d837d3a..2851a78 100644 --- a/lib/BackupPC/CGI/Archive.pm +++ b/lib/BackupPC/CGI/Archive.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/ArchiveInfo.pm b/lib/BackupPC/CGI/ArchiveInfo.pm index c2e209e..6960c00 100644 --- a/lib/BackupPC/CGI/ArchiveInfo.pm +++ b/lib/BackupPC/CGI/ArchiveInfo.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm index 6e927f9..c49eae3 100644 --- a/lib/BackupPC/CGI/Browse.pm +++ b/lib/BackupPC/CGI/Browse.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -37,7 +37,7 @@ 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); @@ -301,7 +301,8 @@ EOF } $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(); diff --git a/lib/BackupPC/CGI/DirHistory.pm b/lib/BackupPC/CGI/DirHistory.pm index 5abcc36..1e374af 100644 --- a/lib/BackupPC/CGI/DirHistory.pm +++ b/lib/BackupPC/CGI/DirHistory.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index 4811f4e..fbf97f9 100644 --- a/lib/BackupPC/CGI/EditConfig.pm +++ b/lib/BackupPC/CGI/EditConfig.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -93,11 +93,21 @@ our %ConfigMenu = ( {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 => { @@ -161,6 +171,7 @@ our %ConfigMenu = ( {name => "XferMethod", onchangeSubmit => 1}, {name => "XferLogLevel"}, {name => "ClientCharset"}, + {name => "ClientCharsetLegacy"}, {text => "CfgEdit_Title_Smb_Settings", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, @@ -758,7 +769,7 @@ EOF next if ( $disabled || $menuDisable{$menu}{top} ); if ( ref($paramInfo->{visible}) eq "CODE" - && !&{$paramInfo->{visible}}($newConf) ) { + && !&{$paramInfo->{visible}}($newConf, $bpc) ) { next; } diff --git a/lib/BackupPC/CGI/EmailSummary.pm b/lib/BackupPC/CGI/EmailSummary.pm index 4871136..8a5304f 100644 --- a/lib/BackupPC/CGI/EmailSummary.pm +++ b/lib/BackupPC/CGI/EmailSummary.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/GeneralInfo.pm b/lib/BackupPC/CGI/GeneralInfo.pm index 5bcea31..dbd74f6 100644 --- a/lib/BackupPC/CGI/GeneralInfo.pm +++ b/lib/BackupPC/CGI/GeneralInfo.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/HostInfo.pm b/lib/BackupPC/CGI/HostInfo.pm index 3331be3..e95ffee 100644 --- a/lib/BackupPC/CGI/HostInfo.pm +++ b/lib/BackupPC/CGI/HostInfo.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/LOGlist.pm b/lib/BackupPC/CGI/LOGlist.pm index f148ff2..e71c7f1 100644 --- a/lib/BackupPC/CGI/LOGlist.pm +++ b/lib/BackupPC/CGI/LOGlist.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index 8370b46..3ba992b 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Queue.pm b/lib/BackupPC/CGI/Queue.pm index dfccc1f..f31f3be 100644 --- a/lib/BackupPC/CGI/Queue.pm +++ b/lib/BackupPC/CGI/Queue.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/RSS.pm b/lib/BackupPC/CGI/RSS.pm index 346fc80..8c90bd6 100644 --- a/lib/BackupPC/CGI/RSS.pm +++ b/lib/BackupPC/CGI/RSS.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/ReloadServer.pm b/lib/BackupPC/CGI/ReloadServer.pm index 8e6db27..3878ead 100644 --- a/lib/BackupPC/CGI/ReloadServer.pm +++ b/lib/BackupPC/CGI/ReloadServer.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Restore.pm b/lib/BackupPC/CGI/Restore.pm index c9eec48..7fe7a5b 100644 --- a/lib/BackupPC/CGI/Restore.pm +++ b/lib/BackupPC/CGI/Restore.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -40,7 +40,7 @@ use strict; use BackupPC::CGI::Lib qw(:all); use Data::Dumper; use File::Path; -use Encode; +use Encode qw/decode_utf8/; sub action { @@ -80,7 +80,7 @@ EOF EOF } $hiddenStr .= "\n"; - $hiddenStr .= "\n"; + $hiddenStr .= "\n"; $badFileCnt++ if ( $In{pathHdr} =~ m{(^|/)\.\.(/|$)} ); $badFileCnt++ if ( $In{num} =~ m{(^|/)\.\.(/|$)} ); if ( @fileList == 0 ) { @@ -113,7 +113,8 @@ EOF # 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 ) { # diff --git a/lib/BackupPC/CGI/RestoreFile.pm b/lib/BackupPC/CGI/RestoreFile.pm index 2a726d2..eebf67a 100644 --- a/lib/BackupPC/CGI/RestoreFile.pm +++ b/lib/BackupPC/CGI/RestoreFile.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -41,7 +41,7 @@ use BackupPC::CGI::Lib qw(:all); 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 { @@ -157,6 +157,10 @@ sub restoreFile 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 ) { # @@ -182,7 +186,8 @@ sub restoreFile 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 diff --git a/lib/BackupPC/CGI/RestoreInfo.pm b/lib/BackupPC/CGI/RestoreInfo.pm index ac7bad5..fb25a12 100644 --- a/lib/BackupPC/CGI/RestoreInfo.pm +++ b/lib/BackupPC/CGI/RestoreInfo.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -38,7 +38,7 @@ package BackupPC::CGI::RestoreInfo; use strict; use BackupPC::CGI::Lib qw(:all); -use Encode; +use Encode qw/decode_utf8/; sub action { @@ -89,6 +89,8 @@ sub action $RestoreReq{hostSrc}:/$strippedShareSrc$f$RestoreReq{hostDest}:/$strippedShareDest$targetFile 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(); diff --git a/lib/BackupPC/CGI/StartServer.pm b/lib/BackupPC/CGI/StartServer.pm index acff95f..8e4dd74 100644 --- a/lib/BackupPC/CGI/StartServer.pm +++ b/lib/BackupPC/CGI/StartServer.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/StartStopBackup.pm b/lib/BackupPC/CGI/StartStopBackup.pm index 697bd0e..8846405 100644 --- a/lib/BackupPC/CGI/StartStopBackup.pm +++ b/lib/BackupPC/CGI/StartStopBackup.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/StopServer.pm b/lib/BackupPC/CGI/StopServer.pm index e3f46dd..0462106 100644 --- a/lib/BackupPC/CGI/StopServer.pm +++ b/lib/BackupPC/CGI/StopServer.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/Summary.pm b/lib/BackupPC/CGI/Summary.pm index 9b26188..f514d0c 100644 --- a/lib/BackupPC/CGI/Summary.pm +++ b/lib/BackupPC/CGI/Summary.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/CGI/View.pm b/lib/BackupPC/CGI/View.pm index ab797e9..02074e2 100644 --- a/lib/BackupPC/CGI/View.pm +++ b/lib/BackupPC/CGI/View.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Config/Meta.pm b/lib/BackupPC/Config/Meta.pm index f21df2d..735c41d 100644 --- a/lib/BackupPC/Config/Meta.pm +++ b/lib/BackupPC/Config/Meta.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -199,6 +199,7 @@ use vars qw(%ConfigMeta); XferLogLevel => "integer", ClientCharset => "string", + ClientCharsetLegacy => "string", SmbShareName => { type => "list", @@ -382,6 +383,7 @@ use vars qw(%ConfigMeta); XferMethod => "boolean", XferLogLevel => "boolean", ClientCharset => "boolean", + ClientCharsetLegacy => "boolean", SmbShareName => "boolean", SmbShareUserName => "boolean", SmbSharePasswd => "boolean", diff --git a/lib/BackupPC/FileZIO.pm b/lib/BackupPC/FileZIO.pm index 294579a..0cf2a9f 100644 --- a/lib/BackupPC/FileZIO.pm +++ b/lib/BackupPC/FileZIO.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Lang/zh_CN.pm b/lib/BackupPC/Lang/zh_CN.pm index 4feb292..a7e6a77 100644 --- a/lib/BackupPC/Lang/zh_CN.pm +++ b/lib/BackupPC/Lang/zh_CN.pm @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/bin/perl #my %lang; #use strict; diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index e1dda82..88db7f8 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -49,7 +49,7 @@ use Socket; 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); @@ -115,7 +115,7 @@ sub new 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 { @@ -130,7 +130,7 @@ sub new my $bpc = bless { %$paths, - Version => '3.0.0', + Version => '3.1.0beta0', }, $class; $bpc->{storage} = BackupPC::Storage->new($paths); @@ -886,6 +886,33 @@ sub MakeFileLink } } +# +# 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) = @_; diff --git a/lib/BackupPC/PoolWrite.pm b/lib/BackupPC/PoolWrite.pm index de166a9..7959a81 100644 --- a/lib/BackupPC/PoolWrite.pm +++ b/lib/BackupPC/PoolWrite.pm @@ -56,7 +56,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Storage.pm b/lib/BackupPC/Storage.pm index 0f7a43e..ed9147d 100644 --- a/lib/BackupPC/Storage.pm +++ b/lib/BackupPC/Storage.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Storage/Text.pm b/lib/BackupPC/Storage/Text.pm index b99648d..7c4f1f7 100644 --- a/lib/BackupPC/Storage/Text.pm +++ b/lib/BackupPC/Storage/Text.pm @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -85,16 +85,15 @@ sub BackupInfoRead } 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; diff --git a/lib/BackupPC/View.pm b/lib/BackupPC/View.pm index 64d5abe..832962e 100644 --- a/lib/BackupPC/View.pm +++ b/lib/BackupPC/View.pm @@ -31,7 +31,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # @@ -46,6 +46,7 @@ use BackupPC::Lib; use BackupPC::Attrib qw(:all); use BackupPC::FileZIO; use Data::Dumper; +use Encode qw/from_to/; sub new { @@ -109,7 +110,8 @@ sub dirCache 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) @@ -118,9 +120,17 @@ sub dirCache $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} ) { # @@ -133,9 +143,9 @@ sub dirCache } 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; } } @@ -152,6 +162,7 @@ sub dirCache || $file eq "." || $file eq "backupInfo" || $mangle && $file eq "attrib" ); + if ( defined($attr) && defined(my $a = $attr->get($fileUM)) ) { $m->{files}{$fileUM} = $a; # @@ -166,7 +177,12 @@ sub dirCache # 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, @@ -180,10 +196,10 @@ sub dirCache # # 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 ) { @@ -198,6 +214,8 @@ sub dirCache ($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} @@ -218,6 +236,8 @@ sub dirCache $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; @@ -378,6 +398,7 @@ sub dirHistory 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) @@ -388,7 +409,15 @@ sub dirHistory $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. @@ -397,7 +426,7 @@ sub dirHistory } 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; @@ -415,7 +444,11 @@ sub dirHistory || $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); @@ -437,7 +470,7 @@ sub dirHistory # # 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"; diff --git a/lib/BackupPC/Xfer/Archive.pm b/lib/BackupPC/Xfer/Archive.pm index a7c9a57..356e6b8 100644 --- a/lib/BackupPC/Xfer/Archive.pm +++ b/lib/BackupPC/Xfer/Archive.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/BackupPCd.pm b/lib/BackupPC/Xfer/BackupPCd.pm index ad3a5a5..5a1e795 100644 --- a/lib/BackupPC/Xfer/BackupPCd.pm +++ b/lib/BackupPC/Xfer/BackupPCd.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/Rsync.pm b/lib/BackupPC/Xfer/Rsync.pm index 67e5296..460e31a 100644 --- a/lib/BackupPC/Xfer/Rsync.pm +++ b/lib/BackupPC/Xfer/Rsync.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/RsyncDigest.pm b/lib/BackupPC/Xfer/RsyncDigest.pm index 3af92f7..85434d7 100644 --- a/lib/BackupPC/Xfer/RsyncDigest.pm +++ b/lib/BackupPC/Xfer/RsyncDigest.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/RsyncFileIO.pm b/lib/BackupPC/Xfer/RsyncFileIO.pm index 221fd3f..fd2df3b 100644 --- a/lib/BackupPC/Xfer/RsyncFileIO.pm +++ b/lib/BackupPC/Xfer/RsyncFileIO.pm @@ -12,7 +12,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm index eed9d9e..f3b5cfd 100644 --- a/lib/BackupPC/Xfer/Smb.pm +++ b/lib/BackupPC/Xfer/Smb.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Xfer/Tar.pm b/lib/BackupPC/Xfer/Tar.pm index 60bfd36..d11bd67 100644 --- a/lib/BackupPC/Xfer/Tar.pm +++ b/lib/BackupPC/Xfer/Tar.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/lib/BackupPC/Zip/FileMember.pm b/lib/BackupPC/Zip/FileMember.pm index 55c4347..8336f14 100644 --- a/lib/BackupPC/Zip/FileMember.pm +++ b/lib/BackupPC/Zip/FileMember.pm @@ -33,7 +33,7 @@ # #======================================================================== # -# Version 3.0.0, released 28 Jan 2007. +# Version 3.1.0beta0, released 3 Sep 2007. # # See http://backuppc.sourceforge.net. # diff --git a/makeDist b/makeDist index 1366c9f..65e4607 100755 --- a/makeDist +++ b/makeDist @@ -53,8 +53,8 @@ die("BackupPC::Lib->new failed\n") 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( @@ -157,6 +157,7 @@ $ConfVars->{LogDir} = 2; $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,