Server Fault is a question and answer site for system and network administrators. 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 have a large directory tree with lot of files like;


I would like to rsync all those directories and files that match thumbnail.jpg to another tree.

I tried;

rsync -r --exclude-from=/tmp/exclude src dst

with exclude file containing;

# cat /tmp/exclude 
+ /thumbnail.jpg
+ thumbnail.jpg
+ /**/thumbnail.jpg
+ **/thumbnail.jpg
- *

but this does not match any.

share|improve this question
up vote 0 down vote accepted

use find

find / -name "thumbnail.jpg" -exec rsync -avz --compress --progress {} dst \;
share|improve this answer
that looks like it would work. though if you had a bazillion files in src and dst was a remote rsync module like serverXXX::modulename, then that would be kinda inefficient...? – Tom H Jul 14 '10 at 9:32

ok, so actually RTFM always works in the end...

changing the command to;

rsync -r --prune-empty-dirs --exclude-from=/tmp/exclude src dst

and changing the exclude file to;

# cat /tmp/exclude 
+ */
+ thumbnail.jpg
- *

works like a charm.

share|improve this answer

Your problem is that the final - * excludes all directories (which tells rsync not just not to copy them but also not to traverse them). Use

+ thumbnail.jpg
+ */
- *

and pass --prune-empty-dirs on the rsync command line.

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.