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?

link|improve this question

75% accept rate
feedback

2 Answers

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.

link|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
feedback

You could do the following

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

then use

rsync --avP --exclude-from=dotfiles ./. user@server:/dir
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.