I have a bunch of log files that I sync with another server using rsync. The log files are all named in the format YYYY-MM-DD XXX.txt. I only want to sync the current month and last month of logs but my filters seem to be conflicting. Here's what I have in my include/exclude file:

- 2009*
- 2010*
- 2011*
- 2012*
- 2013*
+ 2013-03*
+ 2013-04*

The includes/excludes above causes nothing to be synced (I'm assuming because the -2013* appears before the specific months. However, if I remove -2013* from the file above and just leave the 2013-03 and 2013-04, it wants to sync any file beginning with 2013.

I know I'm missing something in the order or format of my filters. Was wondering if anyone had a suggestion. Thank you in advance!


2 Answers 2


- 2013* excludes everything from 2013, this isn't getting reversed if you do a more specific include later.


+ 2013-03*
+ 2013-04*
- 2013* 

and refer to the "Filtering rules" section of the man page for more info.

  • PERFECT - that did the trick. I feel like I just had a DUH moment. Thank you for your help! PS - You can ignore my question to you in a previous thread. Looks like this was the issue!
    – Jason
    Apr 8, 2013 at 21:07

The manual is explicit about this:

As the list of files/directories to transfer is built, rsync checks each name to be transferred against the list of include/exclude patterns in turn, and the first matching pattern is acted on: if it is an exclude pattern, then that file is skipped; if it is an include pattern then that filename is not skipped; if no matching pattern is found, then the filename is not skipped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.