
Using the Exclude Preference Pane
The exclude list is available for each backup set you use. You must check the "Use exclude list" check box to edit the list and enable the exclusions for the backups. The list items now apply to all files and folders listed in the main backuplist+ window.
Drag and Drop files and folders into the exclude list window
You can exclude certain folders and files from your backup session by adding them to the exclude list. They must be added as exclude patterns. If you don't want to enter them yourself you can just drag and drop folders and files onto the list and backuplist+ will create the correct exclude pattern to use. Each item needs to be on a separate line and you should avoid extra spaces between lines.
Options:
Exclude list for backup set....
Check this box to tell backuplist+ to exclude the list items from being copied to the destination.
Delete Excluded
Checking this box will cause any items on the destination that are listed in the exclude list to be deleted, even if they already exist there prior to backup.
Exclude Patterns
You can learn about exclude patterns from the rsync man page. Basically the exclude patterns are UNIX paths that begin at the root of transfer. Do not write your own unless you know what you are doing. Backuplist+ does this for you via drag and drop!
If you are backing up /Users/Home folder/Documents and want to exclude a folder in Documents called "Taxes" you would enter simply
/Documents/Taxes
If you want to exclude a folder called "Federal" within "Taxes" you would enter
/Documents/Taxes/Federal
These paths begin at the root which is the Documents folder. The asterisk * is called a wild card and means anything after the "Federal" directory is also excluded.
If you include the last slash before the asterisk, it will exclude everything inside the folder but not the folder itself.
/Documents/Taxes/Federal/
There is a lot more to exclude patterns. You can exclude any type of file with a certain name or extension. If you want to exclude any .jpg image from the Federal folder, you would put another asterisk before the".jpg" This would exclude file ending in .jpg since the wild card (asterisk) allows for any characters that come before, such as "Taxes/ Federal/taxfile.jpg"
/Documents/Taxes/Federal/*.jpg
If you just drag the files into the list, the excluded files will be specific to your backup source folders. To globally exclude files such as .jpg or hidden .DS_Store files, just add an asterisk before their name in the exclude list:
*.jpg
*.png
*.DS_Store
The following is a brief description of rsync wildcard patterns.
For ADVANCED rsync use see: rsync man page.
Note: All rsync patterns are case sensitive, "d" and "D" are different.
rsync chooses between doing a simple string match and wildcard matching by checking if the pattern contains one of three wildcard characters:
1) A "*" matches any non-empty path component (it stops at slashes "/")
Use "**" to match anything, including slashes.
2) A "?" matches any single character, except a slash "/"
3) A "[" introduces a character class,
such as [a-z] or [[:alpha:]] or [[:space:]]
Wildcard Function
-------- --------
* Matches none, one, or multiple characters
? Matches exactly one character
[a-f] Matches a range of characters
(e.g. all characters "a" "b" "c" "d" "e" "f")
[aeiou] Matches a choice of characters
(e.g. include only characters "a" "e" "i" "o" "u")
[^xyz] Excludes characters ("^" means not)
(e.g. exclude only characters "x" "y" "z")
[[:space:]] Matches a space character
Example Result
------- ------
demo* Everything starting with "demo"
*ing Everything ending with "ing"
ns*.h Everything starting with "ns" and ending with ".h"
?ouse All words with five characters and ending with "ouse"
(e.g. "mouse" or "house")
[a-ez]* Everything starting with "a", "b", "c", "d", "e", or "z"
[d-fk-j]*[gh] Everything starting with "d", "e", "f", "k", "i", or "j"
and ending with "g" or "h"
[^be]* Everything not starting with "b" or "e"
When a file is duplicated by the MacOS it adds the word "copy" to the file name. Sometimes it in just before the file extension and sometimes it is the last word in the file name. A space is also added before the word "copy". A space is a special character that separates options, so use "[[:space:]]" instead.
Examples:
*copy.*
Matches "diary copy.doc" "diary.copy.rtf" "diary-copy.txt"
*[[:space:]]copy.*
Matches "diary copy.doc"
Does not match "diary.copy.rtf" "diary-copy.txt"
*[[:space:]]copy
Matches "diary jan2009.doc copy"
*[[:space:].]copy[[:space:]]*[0-9]
Matches "diary jan2009.doc copy 1" "diary jan2009.doc copy 99"
In a wildcard pattern, a backslash "\" can be used to escape a wildcard character, but it is matched literally when no wildcards are present.
\* Matches only "*", the "\" escapes the wildcard "*"
*\*?oney\** Matches "the *honey* bee.rtf "my *money*.xls"
An excerpt from the man pages is below. You should be familiar with regular expressions before using them - they are powerful tools but could cause loss of important data if you make a mistake!
Rsync man page on EXCLUDE PATTERNS
The exclude and include patterns specified to rsync allow for flexible
selection of which files to transfer and which files to skip.
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. If no matching
include/exclude pattern is found then the filename is not skipped.
The filenames matched against the exclude/include patterns are relative
to the "root of the transfer". If you think of the transfer as a sub-
tree of names that are being sent from sender to receiver, the root is
where the tree starts to be duplicated in the destination directory.
This root governs where patterns that start with a / match (see below).
Because the matching is relative to the transfer-root, changing the
trailing slash on a source path or changing your use of the --relative
option affects the path you need to use in your matching (in addition
to changing how much of the file tree is duplicated on the destination
system). The following examples demonstrate this.
Let's say that we want to match two source files, one with an absolute
path of "/home/me/foo/bar", and one with a path of "/home/you/bar/baz".
Here is how the various command choices differ for a 2-source transfer:
Example cmd: rsync -a /home/me /home/you /dest
+/- pattern: /me/foo/bar
+/- pattern: /you/bar/baz
Target file: /dest/me/foo/bar
Target file: /dest/you/bar/baz
Example cmd: rsync -a /home/me/ /home/you/ /dest
+/- pattern: /foo/bar (note missing "me")
+/- pattern: /bar/baz (note missing "you")
Target file: /dest/foo/bar
Target file: /dest/bar/baz
Example cmd: rsync -a --relative /home/me/ /home/you /dest
+/- pattern: /home/me/foo/bar (note full path)
+/- pattern: /home/you/bar/baz (ditto)
Target file: /dest/home/me/foo/bar
Target file: /dest/home/you/bar/baz
Example cmd: cd /home; rsync -a --relative me/foo you/ /dest
+/- pattern: /me/foo/bar (starts at specified path)
+/- pattern: /you/bar/baz (ditto)
Target file: /dest/me/foo/bar
Target file: /dest/you/bar/baz
The easiest way to see what name you should include/exclude is to just
look at the output when using --verbose and put a / in front of the
name (use the --dry-run option if you're not yet ready to copy any
files).
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.
The exclude patterns actually short-circuit the directory traversal
stage when rsync finds the files to send. If a pattern excludes a par-
ticular parent directory, it can render a deeper include pattern inef-
fectual because rsync did not descend through that excluded section of
the hierarchy.
Note also that the --include and --exclude options take one pattern
each. To add multiple patterns use the --include-from and --exclude-
from options or multiple --include and --exclude options.
The patterns can take several forms. The rules are:
o if the pattern starts with a / then it is matched against the
start of the filename, otherwise it is matched against the end
of the filename. This is the equivalent of a leading ^ in regu-
lar expressions. Thus "/foo" would match a file called "foo" at
the transfer-root (see above for how this is different from the
filesystem-root). On the other hand, "foo" would match any file
called "foo" anywhere in the tree because the algorithm is
applied recursively from top down; it behaves as if each path
component gets a turn at being the end of the file name.
o if the pattern ends with a / then it will only match a direc-
tory, not a file, link, or device.
o if the pattern contains a wildcard character from the set *?[
then expression matching is applied using the shell filename
matching rules. Otherwise a simple string match is used.
o the double asterisk pattern "**" will match slashes while a sin-
gle asterisk pattern "*" will stop at slashes.
o if the pattern contains a / (not counting a trailing /) or a
"**" then it is matched against the full filename, including any
leading directory. If the pattern doesn't contain a / or a "**",
then it is matched only against the final component of the file-
name. Again, remember that the algorithm is applied recursively
so "full filename" can actually be any portion of a path below
the starting directory.
o if the pattern starts with "+ " (a plus followed by a space)
then it is always considered an include pattern, even if speci-
fied as part of an exclude option. The prefix is discarded
before matching.
o if the pattern starts with "- " (a minus followed by a space)
then it is always considered an exclude pattern, even if speci-
fied as part of an include option. The prefix is discarded
before matching.
o if the pattern is a single exclamation mark ! then the current
include/exclude list is reset, removing all previously defined
patterns.
The +/- rules are most useful in a list that was read from a file,
allowing you to have a single exclude list that contains both include
and exclude options in the proper order.
Remember that the matching occurs at every step in the traversal of the
directory hierarchy, so you must be sure that all the parent directo-
ries of the files you want to include are not excluded. This is par-
ticularly important when using a trailing '*' rule. For instance, this
won't work:
+ /some/path/this-file-will-not-be-found
+ /file-is-included
- *
This fails because the parent directory "some" is excluded by the '*'
rule, so rsync never visits any of the files in the "some" or
"some/path" directories. One solution is to ask for all directories in
the hierarchy to be included by using a single rule: --include='*/'
(put it somewhere before the --exclude='*' rule). 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:
+ /some/
+ /some/path/
+ /some/path/this-file-is-found
+ /file-also-included
- *
Here are some examples of exclude/include matching:
o --exclude "*.o" would exclude all filenames matching *.o
o --exclude "/foo" would exclude a file called foo in the trans-
fer-root directory
o --exclude "foo/" would exclude any directory called foo
o --exclude "/foo/*/bar" would exclude any file called bar two
levels below a directory called foo in the transfer-root direc-
tory
o --exclude "/foo/**/bar" would exclude any file called bar two or
more levels below a directory called foo in the transfer-root
directory
o --include "*/" --include "*.c" --exclude "*" would include all
directories and C source files
o --include "foo/" --include "foo/bar.c" --exclude "*" would
include only foo/bar.c (the foo/ directory must be explicitly
included or it would be excluded by the "*")