Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync using --delete but want to not delete symlinks at destination

Tags:

symlink

rsync

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?

like image 465
Diamonds Avatar asked Oct 24 '22 21:10

Diamonds


1 Answers

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

like image 185
Lenz Hirsch Avatar answered Oct 31 '22 10:10

Lenz Hirsch