title: rsync filter excluding everything but given (sub) directories
body: <p>I want to do a Linux system backup with <code>rsync</code> and my backup strategy <strong><em>exclude everything except what I explicitely want</em></strong>. I am not succeeding in finding the correct filter rules.</p>
  
  <p>I have the file <code>sync_filter</code>:</p>
  
  <pre><code>+ /etc
  + /home
  + /opt
  + /root
  + /srv
  + /var/backup
  + /var/log
  + /var/mail
  + /var/www
  - /*
  </code></pre>
  
  <p>I think, my intention is clear. I want to include <code>/etc</code> and so on, I want to include <code>/var/log</code> and <code>/var/mail</code> but I <strong>do not</strong> want to include <code>/var/cache</code>.</p>
  
  <p>I am not succeeding on the <code>/var</code> part.</p>
  
  <p>Running <code>rsync -av --filter "merge sync_filter" --delete root@remote:/ .</code> will skip the <code>/var</code> part completely.</p>
  
  <p>From the documentation, I understand that, e.g. <code>/var/backup</code> is skipped, because <code>/var</code> is excluded by <code>- /*</code> filter.</p>
  
  <p>I also know that I could include <code>+ /var</code> and exclude, e.g. <code>- /var/cache</code> but I'd like to succeed with my backup strategy <strong><em>exclude everything except what I explicitely want</em></strong>.</p>