Problem with exclude folders

Matt McCutchen matt at mattmccutchen.net
Thu Mar 19 17:36:07 GMT 2009


On Thu, 2009-03-19 at 16:26 +0100, Mirko Hufnagel wrote:
> I have a problem with the exclude-from and include-from options.
> 
> I want sync all jpeg files to an external server - exclude HK and texts 
> folders and jpg inside this folders.
> 
> My folder structure are:
> 
> /products/ANYNAME/pictures/EU
> /products/ANYNAME/pictures/HK
> /products/ANYNAME/texts
> ...
> 
> my include-from file:
> 
> */
> *.JPG
> *.jpg
> 
> my exclude-from file:
> 
> */HK/
> */texts
> *
> 
> my rsync command:
> 
> rsync -rvz -W --force --size-only --delete --delete-excluded 
> --include-from=/etc/rsyncfiles.txt --exclude-from=/etc/rsyncexcludes.txt 
>   -e 'ssh -C -p 1000' '/srv/fileserver/products/current product range' 
> IP:/var/products
> 
> Problem 1) all jpeg are copied to the external server - also the jpegs 
> from HK folders. But I only want jpegs from the EU and other folders.
> 
> Problem 2) an empty texts folder was created on the external server - 
> but I don't want this.

The problem is that since you specified the include file before the
exclude file on the command line, everything in the include file takes
priority over everything in the exclude file.  In particular, the
inclusion of */ takes priority over the exclusions of */HK/ and */texts,
which is why you get the HK and texts folders.

Putting all your filters in a single file as Paul suggested will allow
you to prioritize them appropriately.  Note that there's no point in the
*/ prefix in the */HK/ and */texts rules because rsync already allows
unanchored patterns (without leading /) to match any suffix of the path.
I would suggest this filter file, which is the same as Paul's except
that it retains your exclusion of non-jpg files:

- HK/
- texts
+ */
+ *.JPG
+ *.jpg
- *

-- 
Matt



More information about the rsync mailing list