Rsync Include and Exclude with Dates

filterrsync

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!

Best Answer

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

Try

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

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