rsync and symbolic links

Wayne Davison wayned at
Sat Nov 4 16:10:46 GMT 2006

On Sat, Nov 04, 2006 at 10:29:15AM +0100, Gerhard Wiesinger wrote:
> + etc/
> + etc/*
> + etc/.*
> + etc/*/
> + etc/*/*
> + etc/*/.*
> + etc/**/
> + etc/**/*
> + etc/**/.*

Rsync doesn't treat leading dots specially, nor do you need to do a
directory match after doing a match that matches both files and
directories.  Plus, if you're matching all items in the whole hierarchy,
you don't need the directory-limited matching.  So, the above condenses
down to just this:

+ etc/
+ etc/**

Or, if you're running at least 2.6.7 on both sides, you can specify

+ etc/***

which matches both the dir and its contents.

> How can I backup:
> 1.) the symbolic link itself (/etc/myapp.conf)
> 2.) And the file /var/directory1/myapp.conf

You'll need to specify the /var/directory1/myapp.conf file separately to
back it up in addition to the symlink.

One thing you may wish to consider (depending on what your other include
rules are that you left out) is to switch from using includes to using
--files-from.  That lets you specify what to transfer and have the path
information from the source items get duplicates on the destination
(since it implies --relative):

rsync -arv --files-from=list / host:/dest/

(The -r is not redundant when using --files-from.)  Your "list" file
would need to have things like this:


This would send all of /etc, all of /dev, and one extra file.  Add in
whatever else you wish to transfer.


More information about the rsync mailing list