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 ?
In reply to File::Rsync match pattern by rei
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |