-
Notifications
You must be signed in to change notification settings - Fork 1
Excluding files or directories from backups
The WABAC Machine allows you to exclude files and directories from the backup process (well, thanks rsync !).
For example, on OSX, I usually don't backup my .Trash and .cache directories. Some might want to exclude all their .pyc files.
Interested ?
An exclude path is ALWAYS RELATIVE to the source
Even if starting with a /
, an exclude path is ALWAYS RELATIVE to the source.
Allright ? Let's go on !
First, create a file wherever you want (I keep mine with my WABACMachine.sh
file, but that's not mandatory). You can name it however you want. Mine is called exclude
.
We will put the exclusion patterns in this file.
Once your exclusion file is created, modifiy your WABACMachine configuration file. There is an exclude_file
preference in it. Put the absolute path to your exclusion file here.
In your exclusion file, put one pattern per line. If a pattern matches the name of the file that is to be backed up, the file won't be backed up.
A pattern can be a path (relative to the source) to a specific file or directory but it can also be more complicated and can include some wildcards. rsync supports several wildcards. Here are the most useful (for a full list, see rsync manpages):
- A
*
matches any path component, but it stops at slashes. - A
**
matches anything, including slashes. - A
?
matches a single character, except a slash.
Also remember that a pattern that ends with a slash will only match a directory. It won't match a regular file, nor a symlink or a device.
foo
Will exclude a file or a directory named foo in the source directory.
foo/
Will exclude a directory (nothing else) named foo in the source directory.
foo/bar
Will exclude a file (or directory) named bar stored in a directory named foo in the source directory.
foo/*/bar
Will exclude any file (or directory) named bar stored two levels below a directory named foo in the source directory.
foo/**/bar
Will exclude any file (or directory) named bar stored two or more levels below a directory named foo in the source directory.
f*r
Will exclude any file (or directory) with a name starting with f and ending with r stored in the source directory.
f**r
Will exclude any file (or directory) with a realtive path to the source starting with a f and ending with a r. This includes (foobar
, foo/bar
, foo/something/else/bar
, ...).
*.txt
Will exclude all .txt files, no matter where they are stored below source.
WABAC Machine | Copyright © 2009-2016 François Kubler (@fkubler)