0

I have a large directory tree with lot of files like;

/abc2/def/thumbnail.jpg
/abc1/def/thumbnail.jpg
/abc1/def/geh/someothertextfile.txt
/abc1/defe/geh/thumbnail.jpg

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.

Tom
  • 11,176
  • 5
  • 41
  • 63

3 Answers3

0

use find

find / -name "thumbnail.jpg" -exec rsync -avz --compress --progress {} dst \;
topdog
  • 3,520
  • 17
  • 13
  • 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 Jul 14 '10 at 09:32
0

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.

Tom
  • 11,176
  • 5
  • 41
  • 63
0

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.