Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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'm trying to sync all *.jpg files from /var/www/data/models/days/ + some other directories from /var/www/data root.

I do:

rsync -az --delete --include='/models' --include='*.jpg' --exclude='*' $SRC::/var/www/data /var/www/data but it doesn't sync anything. What am I doing wrong?

NOTE: I don't want to change the source or target to include /models/days as I need some other directories with the same filename matching (*.jpg).

share|improve this question

migrated from serverfault.com May 7 '13 at 16:18

This question came from our site for system and network administrators.

up vote 3 down vote accepted

You've included /models in the traversal, but none of its subdirectories. If a directory is excluded, rsync doesn't traverse it, so none of its contents can be included.

Use --include='*/' to include all subdirectories, and -m to not copy directories that would end up empty. For more information, see Rsync filter: copying one pattern only

share|improve this answer

Your --include option needs to take account of leading subdirectory names. Try using **.jpg instead: the rsync-specific ** operator matches slashes as well as other characters.

share|improve this answer
*.jpg matches files in subdirectories as well: if there's no / in the pattern, it's matched against the basename of the file. /*.jpg would only match files at the toplevel. **.jpg is synonymous with *.jpg. – Gilles May 13 '13 at 1:27

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.