Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Assume e.g. you want to backup all files matching pattern a to directory A and all files matching pattern b to directory B. The natural way to do this are two separate rsync commands.

rsync --include="...pattern_a..." --exclude="..." user@server:sourcedir/ a/
rsync --include="...pattern_b..." --exclude="..." user@server:sourcedir/ b/

So far, so good. Now assume that the source dir contains lots (!) of files. Running rsync two times consumes a lot of resources for building the index alone.

Is there a possibility to accomplish things like that in a single rsync run, hence building the index just once?

share|improve this question

1 Answer 1

Create temporary folders on the same file-system, hard-link the files you want into each, then run rsync on each folder.

e.g.

cp -Rl <...glob_pattern_a...> /tmp/tmp_a cp -Rl <...glob_pattern_b...> /tmp/tmp_b

rsync --remove-source-files /tmp/a user@server:destdir_a rsync --remove-source-files /tmp/b user@server:destdir_b

If you want to do this from the dest system, you could put the 'cp' commands in a script on the source sytem.

share|improve this answer

Your Answer

 
discard

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.