rsync preserving symlinks on mirror

Wayne Davison wayned at samba.org
Thu Jun 3 17:41:06 GMT 2004


On Thu, Jun 03, 2004 at 07:23:33PM +0200, Keld J?rn Simonsen wrote:
> I would like to be able to just do a
> symlink from the original tree to the directory on the raid, 

Then you must either (1) tell rsync to expand all symlinks, (2) avoid
having rsync copy the non-matching symlink, (3) duplicate the symlinked
setup on the source so it matches the destination.

The first alternative is easy:  just use the -L option to rsync.  Note
that EVERY symlink will be replaced by the file/dir it points to, so if
you want to preserve symlinks, this option is not going to work.

The second alternative means that you must exclude the non-matching
symlink from the global copy and do an additional copy of the files
inside the symlinked dir.  For instance:

  rsync -av --exclude=/tree/sym /path/tree remote:/mirror
  rsync -av /path/tree/sym/ remote:/mirror/tree/sym

That prevents /tree/sym from ever being copied by rsync, but does copy
its contents (note the trailing slash).

The third option is pretty obvious but is rarely applicable, so I won't
say anything more about it here.

..wayne..


More information about the rsync mailing list