Hello !

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.