Over-writing symlinks

Matt McCutchen matt at mattmccutchen.net
Thu Feb 7 19:39:08 GMT 2008


On Thu, 2008-02-07 at 14:46 +0200, Dale Whitfield wrote:
> I would like to avoid the following situation:
> 
> SRC has:
> -rwxr-xr-x 1 root staff 1596328 2005-04-29 17:34 libc-2.3.3.so
> -rw-r--r-- 1 root staff     193 2005-04-29 17:34 libc.so
> lrwxrwxrwx 1 root staff      13 2007-02-05 15:06 libc.so.6 -> libc-2.3.3.so
> 
> DEST has:
> -rwxr-xr-x 1 dale dale 1558836 2008-02-07 12:25 libc-2.3.6.so
> -rw-r--r-- 1 dale dale     193 2008-02-07 11:46 libc.so
> lrwxrwxrwx 1 dale dale      13 2008-02-07 11:42 libc.so.6 -> libc-2.3.6.so
> 
> If I run:
> 
> rsync --ignore-existing -avn SRC DEST
> 
> output shows the following is to be written to DEST
> 
> libc-2.3.3.so
> libc.so.6 -> libc-2.3.3.so
> 
> How do I avoid libc.so.6 being over-written to point to an old lib?

It looks like --ignore-existing is currently implemented to apply only
to regular files.  I think it was intended to apply to all
non-directories; certainly that is necessary if it is to prevent
undesired tweaking when a --link-dest run is restarted after an
interruption.  I will write a patch to make --ignore-existing apply to
all non-directories after I look into some other weirdness I just
noticed with --ignore-non-existing.

Two approaches you might try in the meantime:

1. Exclude the problematic symlinks, by hand if there are only a few or
otherwise with a script that scans the destination and generates an
--exclude-from file.

2. If both source and destination are local, run "rsync <options> DEST
SRC DEST", i.e., give the destination as an initial source argument.
When rsync unduplicates the file-list, existing destination files will
take priority over source files.  (Attributes on source directories
won't be propagated because the destination attributes will override
them; if you want to propagate the attributes, you could use an extra
run with --include='*/' --exclude='*'.)

Matt



More information about the rsync mailing list