include and exclude file
Matt McCutchen
hashproduct at gmail.com
Sat Apr 15 15:39:38 GMT 2006
On Sat, 2006-04-15 at 02:58 -0400, Marc Collin wrote:
> would like to backup kmail and kwalet in my include file i do:
>
> .kde/share/apps/kmail/
> .kde/share/apps/kwallet/
This is a very common problem that people encounter with includes. If
you exclude .kde, rsync won't even go inside, so it won't notice
that .kde/share/apps/kmail is included.
There are three solutions. I give example filter files that contain
both includes (+) and excludes (-). You pass a filter file filters.txt
to rsync using the option: --filter=". filters.txt"
(1) Show rsync the way to your kmail and kwallet directories by
including the directories along the path. Advantage: It works.
Disadvantage: the include/exclude files are annoying to write, although
I think there's a script somewhere that writes them for you.
Variant 1 (at each level, tell rsync not to stray from the path):
+ .kde/
- .*
+ .kde/share/
- .kde/*
+ .kde/share/apps/
- .kde/share/*
+ .kde/share/apps/kmail/
+ .kde/share/apps/kwallet/
- .kde/share/apps/*
Variant 2 (exclude everything and then re-include subtrees):
+ .kde/
+ .kde/share/
+ .kde/share/apps/
+ .kde/share/apps/kmail/***
+ .kde/share/apps/kwallet/***
- .**
(2) Include all directories, but only include files under the
directories you want. Then prune empty directories. Advantage: the
include/exclude files are really easy to write. Disadvantages: rsync
traverses the whole tree, and if there happen to be empty directories in
the areas you want transferred, they will be skipped.
Filter file:
+ */
+ .kde/share/apps/kmail/***
+ .kde/share/apps/kwallet/***
- .**
Give rsync the option --prune-empty-dirs.
(3) My favorite technique. Sneak under the exclude rule by giving rsync
extra source arguments with --relative. Advantage: works, and you
rarely need any include rules. Disadvantage: somewhat tricky.
Filter file:
- .*
Use a command like this:
rsync --relative $BDIR/./ $BDIR/./.kde/share/apps/kmail/
$BDIR/./.kde/share/apps/kwallet/ $BACKUPDIR
More information about this technique:
http://lists.samba.org/archive/rsync/2006-February/014761.html
Good luck.
--
Matt McCutchen
hashproduct at verizon.net
http://hashproduct.metaesthetics.net/
More information about the rsync
mailing list