rei has asked for the wisdom of the Perl Monks concerning the following question:
I have a problem with the File::Rsync lib.
I try to transfer some log files, matching patterns from a remote /var/log, to my local machine.
Part of my script:
my %rsyncOptions = ( 'recursive' => '1', 'times' => '1', 'ignore-existing' => '1', 'rsh' => '"/usr/bin/ssh"', 'verbose' => '1' ); my $pattern = "\"+ mail.log*\""; push(@includePatterns, $pattern); push(@includePatterns, '"- **"'); #exclude everything else $rsyncOptions{'include'} = \@includePatterns; my $rsync = File::Rsync->new(\%rsyncOptions); my ($cmd, $infun, $outfun, $errfun, $debug) =$rsync->getcmd(%rsyncOpti +ons, 'src' => $sourceDir, 'dest' => $destDir); print "Cmd: " . join(" ", @$cmd) . "\n"; my $sourceDir = "/var/log/"; my $destDir = "log/mail/"; $rsync->exec( { src => $sourceDir, dest => $destDir } );
The getcmd sub give me the following line:
/usr/bin/rsync --ignore-existing --recursive --times --rsh="/usr/bin/ssh" --verbose --include="+ mail.log*" --include="- *" user@XXX.XXX.XXX.XXX:/var/log/ log/mail/So, connection, user, ssh key, dirs and files permissions are ok;
The problem is that the script transfers all my /var/log/ files... But, that's not all: I've tried to execute the command gave by the getcmd, and it works ! rsync just download the mail.log* files...
an idea ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Rsync match pattern
by salva (Canon) on Jul 20, 2011 at 15:24 UTC | |
by rei (Novice) on Jul 21, 2011 at 07:49 UTC | |
by salva (Canon) on Jul 21, 2011 at 08:12 UTC | |
by rei (Novice) on Jul 21, 2011 at 16:21 UTC | |
by salva (Canon) on Jul 22, 2011 at 08:32 UTC |