include/exclude problems

Benjamin R. Haskell rsync at
Fri Mar 26 01:05:37 MDT 2010

On Thu, 25 Mar 2010, Vitaly V. Ganusov wrote:

> However, it seems like a very messy way to sync a given file (by 
> excluding bunch of other files that are not needed). Would you suggest 
> a better way?  Could you suggest a simple way/script to generate such 
> a file (see attached) with only a few files being included in the 
> rsync line?

If you want to transfer only certain files, just list them in a file (relative
to the source directory), and use the --files-from= argument.

E.g., create the file 'test.files'
==== test.files =====================================

Then, using your example: (\'s to avoid mail splitting)

rsync -aunvz --delete -e ssh --files-from=test.files \
 /home/vitaly/ \

Unless I'm mistaken, you can include directories.

If that's not what you meant (a list of specific files), you might just 
be interested to know that you can use '*' to exclude everything not 
already included:

e.g., where you had:

> + .mozilla-thunderbird/
> + .mozilla-thunderbird/afc5fv2p.default/
> + .mozilla-thunderbird/afc5fv2p.default/abook.mab
> + .mozilla-thunderbird/afc5fv2p.default/storage.sdb
> - .mozilla-thunderbird/afc5fv2p.default/ImapMail
> - .mozilla-thunderbird/afc5fv2p.default/Mail
> - .mozilla-thunderbird/afc5fv2p.default/lock
> - .mozilla-thunderbird/afc5fv2p.default/extensions

You could simplify that to:

+ .mozilla-thunderbird/
+ .mozilla-thunderbird/afc5fv2p.default/
+ .mozilla-thunderbird/afc5fv2p.default/abook.mab
+ .mozilla-thunderbird/afc5fv2p.default/storage.sdb
- .mozilla-thunderbird/afc5fv2p.default/*

(The last line *doesn't* exclude abook.mab or storage.sdb)


More information about the rsync mailing list