title: Bash: find with -depth and -prune to feed cpio
body: <p>I'm building a backup script where some directories should not be included in the backup archive.</p>
  
  <pre><code>cd /;
  find . -maxdepth 2 \ 
      \( -path './sys' -o -path './dev' -o -path './proc' -o -path './media' -o -path './mnt' \) -prune \
  -o -print
  </code></pre>
  
  <p>This finds only the files and directories I want.</p>
  
  <p>Problem is that <code>cpio</code> should be fed with the following option in order to avoid problems with permissions when restoring files.</p>
  
  <pre><code>find ... -depth ....
  </code></pre>
  
  <p>And if I add the <code>-depth</code> option, returned files and directories include those I want to avoid.</p>
  
  <p>I really don't understand these sentences from the find manual:</p>
  
  <pre><code>-prune True;  if  the  file is a directory, do not descend into it. If
                -depth is given, false; no  effect.   Because  -delete  implies
                -depth, you cannot usefully use -prune and -delete together.
  </code></pre>