Server Fault is a question and answer site for system and network administrators. 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

For the sake of this post, lets assume I have a folder called "misc" that has 100 sub-folder named 001 to 100. Each folder has many sub-folders and files.

I want to write one rsync command that recursively backs up only the folders named 009, 053, and 087.

This command works fine for backing up the entire "misc" folder:

rsync -v --progress --recursive /home/user/misc /home/user/backup/misc

I've made several attempts to use include and exclude parameters (to only backup the particular sub-folders I want), but each attempt has resulted in /home/user/backup/misc being an empty folder after the command is run successfully.

Could someone add to this command (above) the proper use of include and exclude parameters to achieve what I'm attempting?

share|improve this question
up vote 4 down vote accepted

rsync -avz will backup all files, recursively. If you script your rsync into a bash script, you can just back those particular folders


rsync -avz /home/user/misc/009 /home/user/backup/misc/
rsync -avz /home/user/misc/053 /home/user/backup/misc/
rsync -avz /home/user/misc/087 /home/user/backup/misc/
share|improve this answer
This is very nice approach and I may use it ultimately. However, I'm still very interested in how to achieve this using one rsync command with include/exclude statements. – LonnieBest Sep 28 '13 at 4:34
Include/Exclude are meant more for filenames. Example: rsync -avz /home/user/misc /home/user/backup/ --exclude "exe" would backup everything in /home/user/misc except files with "exe" in it. I guess, technically, you could do --include "folder/" --exclude "*" and it should exclude everything, then include the folder (but I'm fairly certain you can only explicity include 1 thing and explicitly exclude 1 thing, which means you'll need a script anyway). If you need more info about it, you can read the man page: – CIA Sep 28 '13 at 5:11

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.