<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Rsync_exclude%2Finclude_pattern_rules</id>
		<title>Rsync exclude/include pattern rules - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Rsync_exclude%2Finclude_pattern_rules"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Rsync_exclude/include_pattern_rules&amp;action=history"/>
		<updated>2026-05-06T12:23:09Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Rsync_exclude/include_pattern_rules&amp;diff=1545&amp;oldid=prev</id>
		<title>George2 at 13:48, 11 December 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Rsync_exclude/include_pattern_rules&amp;diff=1545&amp;oldid=prev"/>
				<updated>2014-12-11T13:48:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:48, 11 December 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;INCLUDE/EXCLUDE PATTERN RULES&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;INCLUDE/EXCLUDE PATTERN RULES&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>George2</name></author>	</entry>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Rsync_exclude/include_pattern_rules&amp;diff=1544&amp;oldid=prev</id>
		<title>George2: Created page with &quot;&lt;source lang=&quot;text&quot;&gt;  INCLUDE/EXCLUDE PATTERN RULES  You can include and exclude files by specifying patterns using the &quot;+&quot;, &quot;-&quot;, etc. filter rules (as introduced in the FILTE...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Rsync_exclude/include_pattern_rules&amp;diff=1544&amp;oldid=prev"/>
				<updated>2014-12-11T13:48:01Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;  INCLUDE/EXCLUDE PATTERN RULES  You can include and exclude files by specifying patterns using the &amp;quot;+&amp;quot;, &amp;quot;-&amp;quot;, etc. filter rules (as introduced in the FILTE...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
INCLUDE/EXCLUDE PATTERN RULES&lt;br /&gt;
&lt;br /&gt;
You can include and exclude files by specifying patterns using the &amp;quot;+&amp;quot;, &amp;quot;-&amp;quot;, etc. filter rules (as introduced in the FILTER RULES section above). The include/exclude rules each specify a pattern that is matched against the names of the files that are going to be transferred. These patterns can take several forms:&lt;br /&gt;
&lt;br /&gt;
    if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus &amp;quot;/foo&amp;quot; would match a name of &amp;quot;foo&amp;quot; at either the &amp;quot;root of the transfer&amp;quot; (for a global rule) or in the merge-file's directory (for a per-directory rule). An unqualified &amp;quot;foo&amp;quot; would match a name of &amp;quot;foo&amp;quot; anywhere in the tree because the algorithm is applied recursively from the top down; it behaves as if each path component gets a turn at being the end of the filename. Even the unanchored &amp;quot;sub/foo&amp;quot; would match at any point in the hierarchy where a &amp;quot;foo&amp;quot; was found within a directory named &amp;quot;sub&amp;quot;. See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify a pattern that matches at the root of the transfer.&lt;br /&gt;
    if the pattern ends with a / then it will only match a directory, not a regular file, symlink, or device.&lt;br /&gt;
    rsync chooses between doing a simple string match and wildcard matching by checking if the pattern contains one of these three wildcard characters: '*', '?', and '[' .&lt;br /&gt;
    a '*' matches any path component, but it stops at slashes.&lt;br /&gt;
    use '**' to match anything, including slashes.&lt;br /&gt;
    a '?' matches any character except a slash (/).&lt;br /&gt;
    a '[' introduces a character class, such as [a-z] or [[:alpha:]].&lt;br /&gt;
    in a wildcard pattern, a backslash can be used to escape a wildcard character, but it is matched literally when no wildcards are present. This means that there is an extra level of backslash removal when a pattern contains wildcard characters compared to a pattern that has none. e.g. if you add a wildcard to &amp;quot;foo\bar&amp;quot; (which matches the backslash) you would need to use &amp;quot;foo\\bar*&amp;quot; to avoid the &amp;quot;\b&amp;quot; becoming just &amp;quot;b&amp;quot;.&lt;br /&gt;
    if the pattern contains a / (not counting a trailing /) or a &amp;quot;**&amp;quot;, then it is matched against the full pathname, including any leading directories. If the pattern doesn't contain a / or a &amp;quot;**&amp;quot;, then it is matched only against the final component of the filename. (Remember that the algorithm is applied recursively so &amp;quot;full filename&amp;quot; can actually be any portion of a path from the starting directory on down.)&lt;br /&gt;
    a trailing &amp;quot;dir_name/***&amp;quot; will match both the directory (as if &amp;quot;dir_name/&amp;quot; had been specified) and everything in the directory (as if &amp;quot;dir_name/**&amp;quot; had been specified). This behavior was added in version 2.6.7. &lt;br /&gt;
&lt;br /&gt;
Note that, when using the --recursive (-r) option (which is implied by -a), every subcomponent of every path is visited from the top down, so include/exclude patterns get applied recursively to each subcomponent's full name (e.g. to include &amp;quot;/foo/bar/baz&amp;quot; the subcomponents &amp;quot;/foo&amp;quot; and &amp;quot;/foo/bar&amp;quot; must not be excluded). The exclude patterns actually short-circuit the directory traversal stage when rsync finds the files to send. If a pattern excludes a particular parent directory, it can render a deeper include pattern ineffectual because rsync did not descend through that excluded section of the hierarchy. This is particularly important when using a trailing '*' rule. For instance, this won't work:&lt;br /&gt;
&lt;br /&gt;
    + /some/path/this-file-will-not-be-found&lt;br /&gt;
    + /file-is-included&lt;br /&gt;
    - *&lt;br /&gt;
&lt;br /&gt;
This fails because the parent directory &amp;quot;some&amp;quot; is excluded by the '*' rule, so rsync never visits any of the files in the &amp;quot;some&amp;quot; or &amp;quot;some/path&amp;quot; directories. One solution is to ask for all directories in the hierarchy to be included by using a single rule: &amp;quot;+ */&amp;quot; (put it somewhere before the &amp;quot;- *&amp;quot; rule), and perhaps use the --prune-empty-dirs option. Another solution is to add specific include rules for all the parent dirs that need to be visited. For instance, this set of rules works fine:&lt;br /&gt;
&lt;br /&gt;
    + /some/&lt;br /&gt;
    + /some/path/&lt;br /&gt;
    + /some/path/this-file-is-found&lt;br /&gt;
    + /file-also-included&lt;br /&gt;
    - *&lt;br /&gt;
&lt;br /&gt;
Here are some examples of exclude/include matching:&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;- *.o&amp;quot; would exclude all names matching *.o&lt;br /&gt;
    &amp;quot;- /foo&amp;quot; would exclude a file (or directory) named foo in the transfer-root directory&lt;br /&gt;
    &amp;quot;- foo/&amp;quot; would exclude any directory named foo&lt;br /&gt;
    &amp;quot;- /foo/*/bar&amp;quot; would exclude any file named bar which is at two levels below a directory named foo in the transfer-root directory&lt;br /&gt;
    &amp;quot;- /foo/**/bar&amp;quot; would exclude any file named bar two or more levels below a directory named foo in the transfer-root directory&lt;br /&gt;
    The combination of &amp;quot;+ */&amp;quot;, &amp;quot;+ *.c&amp;quot;, and &amp;quot;- *&amp;quot; would include all directories and C source files but nothing else (see also the --prune-empty-dirs option)&lt;br /&gt;
    The combination of &amp;quot;+ foo/&amp;quot;, &amp;quot;+ foo/bar.c&amp;quot;, and &amp;quot;- *&amp;quot; would include only the foo directory and foo/bar.c (the foo directory must be explicitly included or it would be excluded by the &amp;quot;*&amp;quot;) &lt;br /&gt;
&lt;br /&gt;
The following modifiers are accepted after a &amp;quot;+&amp;quot; or &amp;quot;-&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
    A / specifies that the include/exclude rule should be matched against the absolute pathname of the current item. For example, &amp;quot;-/ /etc/passwd&amp;quot; would exclude the passwd file any time the transfer was sending files from the &amp;quot;/etc&amp;quot; directory, and &amp;quot;-/ subdir/foo&amp;quot; would always exclude &amp;quot;foo&amp;quot; when it is in a dir named &amp;quot;subdir&amp;quot;, even if &amp;quot;foo&amp;quot; is at the root of the current transfer.&lt;br /&gt;
    A ! specifies that the include/exclude should take effect if the pattern fails to match. For instance, &amp;quot;-! */&amp;quot; would exclude all non-directories.&lt;br /&gt;
    A C is used to indicate that all the global CVS-exclude rules should be inserted as excludes in place of the &amp;quot;-C&amp;quot;. No arg should follow.&lt;br /&gt;
    An s is used to indicate that the rule applies to the sending side. When a rule affects the sending side, it prevents files from being transferred. The default is for a rule to affect both sides unless --delete-excluded was specified, in which case default rules become sender-side only. See also the hide (H) and show (S) rules, which are an alternate way to specify sending-side includes/excludes.&lt;br /&gt;
    An r is used to indicate that the rule applies to the receiving side. When a rule affects the receiving side, it prevents files from being deleted. See the s modifier for more info. See also the protect (P) and risk (R) rules, which are an alternate way to specify receiver-side includes/excludes.&lt;br /&gt;
    A p indicates that a rule is perishable, meaning that it is ignored in directories that are being deleted. For instance, the -C option's default rules that exclude things like &amp;quot;CVS&amp;quot; and &amp;quot;*.o&amp;quot; are marked as perishable, and will not prevent a directory that was removed on the source from being deleted on the destination. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>