This question already has an answer here:

so it seems like there are others with the same problem, but I couldn't find the right solution for myself. What I want to do: Rsync all files with pattern .log. but exclude a directory

Here is my rsync command:

rsync --include=*/ --include=*.log.*  --exclude=* --exclude=folder1/ -armte "ssh -o StrictHostKeyChecking=no" user@server:/path/log/ /tmp/rsynctest/

So in /path/log are multiple subfolders. /path/log/folder0 /path/log/folder1 /path/log/folder2 etc. And I want to exclude one of them (folder1). But rsync is still syncing this folder. I'm not really sure what I'm doing wrong.

marked as duplicate by Gilles 'SO- stop being evil', G-Man Says 'Reinstate Monica', Anthony G - justice for Monica, Jan, GAD3R Sep 13 '16 at 9:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • remove trailing / at folder1. use only --exclude=folder1 – Rahul Sep 13 '16 at 6:24
  • Thanks for the fast reply. But unfortunately it doesent work. Its still getting synced – M.S. Sep 13 '16 at 6:40
  • See our generic guide. Order matters: here the first include rule includes all directories. You need to move --exclude=folder1/ first. – Gilles 'SO- stop being evil' Sep 13 '16 at 6:44
  • Thats it! Damn I should get that myself. Thanks anyway! – M.S. Sep 13 '16 at 6:50

Browse other questions tagged or ask your own question.