2

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?

3

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.

  • 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
0

You could do the following

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

then use

rsync --avP --exclude-from=dotfiles ./. user@server:/dir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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