title: How do you get rsync to exclude any directory named cache?
body: <p>I'm new to rsync and have read a bit about excluding files and directories but I don't fully understand and can't seem to get it working.</p>
  
  <p>I'm simply trying to run a backup of all the websites in a server's webroot but don't want any of the CMS's cache files.</p>
  
  <p>Is there away to exclude any directory named cache?</p>
  
  <p>I've tried a lot of things over the weeks (that I don't remember), but more recently I've been trying these sorts of things:</p>
  
  <pre><code>sudo rsync -avzO -e --exclude *cache ssh username@11.22.33.44:/home/ /Users/username/webserver-backups/DEV/home/
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>sudo rsync -avzO -e --exclude cache/ ssh username@11.22.33.44:/home/ /Users/username/webserver-backups/DEV/home/
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>sudo rsync -avzO -e --exclude */cache/ ssh username@11.22.33.44:/home/ /Users/username/webserver-backups/DEV/home/
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>sudo rsync -avzO -e --exclude *cache/ ssh username@11.22.33.44:/home/ /Users/username/webserver-backups/DEV/home/
  </code></pre>
  
  <p>Sorry if this is easy, I just haven't been able to find info that I understand because they all talk about a path to exclude.</p>
  
  <p>It's just that I don't have a specific path I want to exclude - just a directory name if that makes sense.</p>