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.

| improve this question | | | | |
0

use find

find / -name "thumbnail.jpg" -exec rsync -avz --compress --progress {} dst \;
| 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
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.

| improve this answer | | | | |
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.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.