Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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
    
linux.die.net/man/1/rsync 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

 
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.