include and exclude file

Marc Collin collinm at laboiteaprog.com
Sat Apr 15 18:05:50 GMT 2006


Le Samedi 15 Avril 2006 11:39, Matt McCutchen a écrit :

> 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/***
> - .**

i tried variant 2 and that work fine

in the first variant you write 
-.*
in the second variant you write
-.**

where to get information about *?
the number of * seem to have an impact...
> (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.

rsync  version 2.6.6  protocol version 29
don't seem to have this option

i tried without prune...

rsync -a -r -v -p -t --del --include-from=include.txt 
--exclude-from=exclude.txt 
--filter=filters.txt /home/collinm /tmp/test_backup


Unknown filter rule: `filters.txt'
rsync error: syntax or usage error (code 1) at exclude.c(759)

my include file: 
.kde/share/apps/kabc/
.kde/share/apps/kmail/
.kde/share/apps/kwallet/


exclude file
rpm/
mp3/
Download/
.*

> (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

this approach work fine and i not create a filter rule file.....

this approchoad copy BDIR=/home/$USER

/tmp/test_backup/home/joe

with this technic can i have /tmp/test_backup/joe

> 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