- $conf->{RsyncShareName} = [ $conf->{RsyncShareName} ]
- unless ref($conf->{RsyncShareName}) eq "ARRAY";
- foreach my $param qw(BackupFilesOnly BackupFilesExclude) {
- next if ( !defined($conf->{$param}) );
- if ( ref($conf->{$param}) eq "ARRAY" ) {
- $conf->{$param} = {
- $conf->{RsyncShareName}[0] => $conf->{$param}
- };
- } elsif ( ref($conf->{$param}) eq "HASH" ) {
- # do nothing
- } else {
- $conf->{$param} = {
- $conf->{RsyncShareName}[0] => [ $conf->{$param} ]
- };
- }
- }
+ $bpc->backupFileConfFix($conf, "RsyncShareName");
+
+ if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) {
+ my(@inc, @exc, %incDone, %excDone);
+ foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) {
+ #
+ # If the user wants to just include /home/craig, then
+ # we need to do create include/exclude pairs at
+ # each level:
+ # --include /home --exclude /*
+ # --include /home/craig --exclude /home/*
+ #
+ # It's more complex if the user wants to include multiple
+ # deep paths. For example, if they want /home/craig and
+ # /var/log, then we need this mouthfull:
+ # --include /home --include /var --exclude /*
+ # --include /home/craig --exclude /home/*
+ # --include /var/log --exclude /var/*
+ #
+ # To make this easier we do all the includes first and all
+ # of the excludes at the end (hopefully they commute).
+ #
+ $file =~ s{/$}{};
+ $file = "/$file";
+ $file =~ s{//+}{/}g;
+ if ( $file eq "/" ) {
+ #
+ # This is a special case: if the user specifies
+ # "/" then just include it and don't exclude "/*".
+ #
+ push(@inc, $file) if ( !$incDone{$file} );
+ next;
+ }
+ my $f = "";
+ while ( $file =~ m{^/([^/]*)(.*)} ) {
+ my $elt = $1;
+ $file = $2;
+ if ( $file eq "/" ) {
+ #
+ # preserve a tailing slash
+ #
+ $file = "";
+ $elt = "$elt/";
+ }
+ push(@exc, "$f/*") if ( !$excDone{"$f/*"} );
+ $excDone{"$f/*"} = 1;
+ $f = "$f/$elt";
+ push(@inc, $f) if ( !$incDone{$f} );
+ $incDone{$f} = 1;
+ }
+ }
+ foreach my $file ( @inc ) {
+ $file = encode($conf->{ClientCharset}, $file)
+ if ( $conf->{ClientCharset} ne "" );
+ push(@fileList, "--include=$file");
+ }
+ foreach my $file ( @exc ) {
+ $file = encode($conf->{ClientCharset}, $file)
+ if ( $conf->{ClientCharset} ne "" );
+ push(@fileList, "--exclude=$file");
+ }
+ }