Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>rsync</code> doesn't work like that. Any file with a filename pattern that does not match any of the include or exclude patterns are considered to be included. In other words, think of the include pattern as a way of overriding exclude pattern.</p> <p>From the <a href="http://www.linuxmanpages.com/man1/rsync.1.php" rel="noreferrer">docs</a>:</p> <p>Rsync builds an ordered list of include/exclude options as specified on the command line. Rsync checks each file and directory name against each exclude/include pattern in turn. The first matching pattern is acted on. If it is an exclude pattern, then that file is skipped. If it is an include pattern then that filename is not skipped. <strong>If no matching include/exclude pattern is found then the filename is not skipped.</strong></p> <p>(Emphasis mine)</p> <p>So, if you want to include only specific files, you first need to <em>include</em> those specific files, then <em>exclude</em> all other files:</p> <pre><code>--include="*/" --include="*.cfg" --exclude="*" </code></pre> <p>Couple of things to note here:</p> <ol> <li><p>The <code>include</code> patterns have to come before the excludes, because the first pattern that matches is the one that gets considered. If the file name matches the exclude pattern first, it gets excluded.</p></li> <li><p>You need to either include all subdirectories individually, like <code>--include="/opt" --include="/opt/dir1"</code> etc. for all subdirectories, or use --include="*/" to include all directories (not files). I went with the second option for brevity.</p></li> </ol> <p>It is quirky and not very intuitive. So read the <a href="http://www.linuxmanpages.com/man1/rsync.1.php" rel="noreferrer">docs</a> carefully (the "EXCLUDE PATTERNS" section in the link) and use the <code>--dry-run</code> or <code>-n</code> option to make sure it is going to do what you think it should do.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload