Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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

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


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


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.