5
votes

Using rsync, my source directory has a number of files and directories. My destination already has been synced, so it mirrors those files and directories.

However, I have manually created a symlink in my destination that does not exist in my source.

I need to use the --delete operation in rsync. Is there a way to get rsync to not remove the symlink?

2
Maybe --copy-dirlinks will help you if your symlink is to a directory, not to a regular file. - 9000

2 Answers

5
votes

There is no option to achieve this the way you suggested BUT the simplest solution to the described problem is just to add the filenames of the symlinks to the rsync exclude pattern

like: --exclude="folder/symlinkname1" --exclude="folder/symlinkname2"

if there are many symlinks you can keep a list of them in a exclude pattern file this file may be autogenerated by a little script or a bash one liner...

-2
votes

Does your destination existing symlink point to a directory or file? If a directory, you may be able to use --keep-dirlinks.