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

I'm trying to set up an rsync that excludes all .* files except for .htaccess but unfortunately, this doesn't work:

rsync -avP --exclude=".*" --include="./.htaccess" ./. user@server:/dir

Is it possible to somehow exclude general exclude rules?

share|improve this question
up vote 2 down vote accepted

Just reverse the order of your arguments:

rsync -avP --include="./.htaccess" --exclude=".*" ./. user@server:/dir

The first matching pattern wins. For more information, see the FILTER RULES section of the rsync(1) manpage.

share|improve this answer for reference. – Andrew Apr 11 '11 at 1:16
Unfortunately that didn't work, but dropping the "./" in front of "./.htaccess" did. – Rich Apr 11 '11 at 18:25

You could do the following

find . -type f -name ".*" |grep -v .htaccess > dotfiles

then use

rsync --avP --exclude-from=dotfiles ./. user@server:/dir
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.