rsync : how to exclude specific files or folders ?
smoot at tic.com
Sun Mar 1 20:39:41 UTC 2009
On Sat, 2009-02-28 at 21:19 -0500, H.S. wrote:
> Matthew Flaschen wrote:
> > Vincent Trouilliez wrote:
> >> Oh ! After reading your mail, and re-re-re-reading the man page, I ventured into this:
> >> $rsync <options> --exclude '*.VirtualBox' --exclude '*.googleearth' <source> <destination>
> >> and it worked !
> > Yes, and if you want to switch from a chain of exclude parameters to a
> > file (e.g. if the command line starts getting long), you can just do:
> > rsync <options> --exclude-from=my_exclude_file <source> <destination>
> > And my_exclude_file is then just:
> > *.VirtualBox
> > *.googleearth
> The asterisks are needed. ".foo" will match a file any file called .foo
> in any path. See first rule in section EXCLUDE PATTERNS in rsync man page.
Not quite correct although it is a bit confusing. The above will match
any file which ends with .VirtualBox or .googleearth. If you start your
transfer from say, /home/user, and want to exclude the above directories
at that level in the hierarchy then the precise syntax would be:
The leading "/" says to match only at the root of the transfer. Any
instance of .VirtualBox which appears anywhere else will be included.
As a practical matter, it likely does not matter, since it is unlikely
you have another file or directory in your home directory
called .VirtualBox or .googleearth. As another poster indicated you can
see what rsync does this with the --dry-run and --verbose option.
For more complex filtering take a look at the --filter option. It
allows all kinds of sophisticated file inclusion/exclusion.
Computer Systems and
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005
More information about the ubuntu-users