on server1: /dir1 is a symlink to dir2
on server2: /dir1 is a directory with its own content
I want to use rsync to make server2:/dir1 be a symlink to dir2, just as it is on server1.
If I do this on server1:
rsync -azvs --delete /dir1 user@server2:/dir1
then I actually get a new (broken) symlink on server2:
/dir1/dir1 -> dir2
(so it's copying the symlink into the existing /dir1 directory instead of replacing it)
Can I instead get rsync to trample the existing /dir1 directory with the symlink?
Edit: I thought the above command would work because of this comment in the man for rsync under the --copy-dirlinks
section:
Without this option, if the sending side has replaced a directory with a symlink to a directory, the receiving side will delete anything that is in the way of the new symlink, including a directory hierarchy (as long as --force or --delete is in effect).
However, the behavior appears the same with and without --force
, and with and without -k
.