# -p pathAdd new path prefix
# -b BLOCKS BLOCKS x 512 bytes per record (default 20; same as tar)
# -w writeBufSz write buffer size (default 1MB)
+# -e charset charset for encoding file names (default: value of
+# $Conf{ClientCharset} when backup was done)
#
# 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
#
#========================================================================
#
-# Version 2.1.0, released 20 Jun 2004.
+# Version 3.0.0, released 28 Jan 2007.
#
# See http://backuppc.sourceforge.net.
#
use lib "/usr/local/BackupPC/lib";
use File::Path;
use Getopt::Std;
+use Encode qw/from_to/;
use BackupPC::Lib;
use BackupPC::Attrib qw(:all);
use BackupPC::FileZIO;
use BackupPC::View;
die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
-my $TopDir = $bpc->TopDir();
-my $BinDir = $bpc->BinDir();
-my %Conf = $bpc->Conf();
my %opts;
-if ( !getopts("th:n:p:r:s:b:w:", \%opts) || @ARGV < 1 ) {
+if ( !getopts("te:h:n:p:r:s:b:w:", \%opts) || @ARGV < 1 ) {
print STDERR <<EOF;
usage: $0 [options] files/directories...
Required options:
-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)
EOF
exit(1);
}
-if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) {
+if ( $opts{h} !~ /^([\w\.\s-]+)$/
+ || $opts{h} =~ m{(^|/)\.\.(/|$)} ) {
print(STDERR "$0: bad host name '$opts{h}'\n");
exit(1);
}
exit(1);
}
+my $Charset = $Backups[$i]{charset};
+$Charset = $opts{e} if ( $opts{e} ne "" );
+
my $PathRemove = $1 if ( $opts{r} =~ /(.+)/ );
my $PathAdd = $1 if ( $opts{p} =~ /(.+)/ );
-if ( $opts{s} !~ /^([\w\s\.\/\$-]+)$/ && $opts{s} ne "*" ) {
+if ( $opts{s} =~ m{(^|/)\.\.(/|$)} ) {
print(STDERR "$0: bad share name '$opts{s}'\n");
exit(1);
}
+
our $ShareName = $opts{s};
our $view = BackupPC::View->new($bpc, $Host, \@Backups);
{
my($fh, $hdr) = @_;
+ #
+ # Convert path names to requested (eg: client) charset
+ #
+ if ( $Charset ne "" ) {
+ from_to($hdr->{name}, "utf8", $Charset);
+ from_to($hdr->{linkname}, "utf8", $Charset);
+ }
+
#
# Handle long link names (symbolic links)
#
TarWrite($fh, \$data);
TarWritePad($fh, length($data));
}
+
#
# Handle long file names
#
$arg = "/" if ( $arg eq "." );
$arg =~ s{^\./+}{/};
$arg =~ s{/+$}{};
- $done = 1 if ( $name eq $arg || $name =~ /^\Q$arg\// );
+ $done = 1 if ( $name eq $arg || $name =~ /^\Q$arg\// || $arg eq "" );
}
}
if ( $done ) {