rsync and symbolic links

Gerhard Wiesinger lists at
Sat Nov 4 17:39:19 GMT 2006

On Sat, 4 Nov 2006, Wayne Davison wrote:

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

Ok, thnx. To be more precise I'm generating the include file with a 
small perl script from a static configuration and with rpm -qal to specify 
the configuration. But some configuration files are outside of rpm.

> Or, if you're running at least 2.6.7 on both sides, you can specify
> this:
> + etc/***

Ok, thnx.

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

Yes, that is exactly the problem. I have to parse e.g. the whole /etc 
directory tree for symlinks and specify the link and the link destination 
separetly. So turns out that I want a "feature request" which copies the 
link itself (file or directory) and the linked file/directory itself. So 
then I have a "perfect" backup (the link is not valid when it is absolute 
but it works well on restore). Currently I only have the symbolic link of 
the file/directory but not the contents itself (which is useless on 
restore because I don't have the data).

> 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:
> etc
> dev
> var/directory1/myapp.conf

Yes, same problem here: I have to specify the link from /etc to 
var/directory1/myapp.conf, which means manually parsing the etc tree.

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

So basically I want to make a backup of all my configuration files and 
home directories. Some configuration from /etc is linked outside of /etc 
(e.g. the /var/directory1 tree), but I don't want to specify the whole 
/var/ stuff to the include list, because the backup set is much too large 
for a daily backup. (I know I can make a hardlink backup with previous 
versions, too.)

When the feature with copying the link itself and the contents would be 
implemented I have a "perfect" copy. When I copy the files backup on 
disaster recovery the links work well again. (after replacing the OS).

Do you plan to implement this feature request?

Thank you for the answer.



More information about the rsync mailing list