Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I'm trying to combine multiple rsync commands into one command. Currently I use the following command:

/usr/bin/rsync --exclude-from=/directory/exclude.txt --delete --rsync-path "/usr/bin/sudo /usr/bin/rsync" -e 'ssh' -rtogpu /directory user@server:/directory

This command is executed 5 times with different directories. I've tried to combine these 5 commands into one command using --include-from=include.txt and --files-from=include.txt like this:

/usr/bin/rsync  --delete --rsync-path "/usr/bin/sudo /usr/bin/rsync" -e 'ssh' -rtogpu --files-from=/directory/include user@server:/directory

Unfortunately this didn't do the trick, is there a good way to do this with rsync? And if so how would I be able to do that?

Just to be clear, I need to synchronize the entire content of the directories, not just single files.

Thanks in advance!


My include file is like this:


I've tried it with and without trailing slashes at the end as Roomney suggested but it didn't matter.

share|improve this question
Show us the include file. – Zoredache Apr 23 '12 at 15:48
I've edited the OP. – Meatje Apr 23 '12 at 16:26
A bit too busy this second to add an answer, but you need to look more a the Include/Exclude Pattern Rules section of the man page. To include a directory you want something like /foo/***. – Zoredache Apr 23 '12 at 16:46

I am not sure what how exactly using --include-from=include.txt is not working for you. In your include.txt file, firstly make sure it is either in your current directory, or use an absolute path to it.

Within include.txt, make sure you have an absolute path to each folder with no trailing slash. Also, you may want to try the command without --files-from=include.txt as I'm not sure if it is required. I hope this helps a bit!

share|improve this answer
Hi, zoredache could be right, never got a chance to check, but your second command seems to be missing the 'include-from' argument, is that a typo? It looks like your defining the includes twice maybe (i might have misread that) – Rqomey Apr 23 '12 at 18:18

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.