How to prevent rsync replacing symbolic links with new directories in the target directory hierarchy

rsyncsymbolic-link

I am using rsync(1) to synchronize files between a source area and a target area, where the target directory hierarchy contains symbolic links.

When a source directory has the same name and relative path as a symbolic link in the target area, then rsync replaces the symbolic link with the copied source directory and all its contents. I want rsync to instead leave the symbolic link intact, and only copy files that would have been copied had the symbolic link been a real directory.

I'm currently using -Cvrtp options to rsync. I'm aware of the --links option, but that appears to relate only to symbolic links in the source area.

Is there a way to obtain the behaviour I'm looking for with rsync?

Best Answer

No sooner had I asked the question, then I discovered the answer:

The -K / --keep-dirlinks rsync option would appear to be exactly what I'm looking for.