Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 1 down vote accepted

- 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.

share|improve this answer
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 '13 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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