I'm using rsync
to backup some of my files:
rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/"
The --link-dest
option works fine with most files, but not with symlinks.
When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied.
Now I'm wondering:
Is there a way to make rsync
hard-link unchanged symlinks as well?
And if not: Is it intentional or a bug in rsync?
I'm using rsync version 3.1.1 on Mac OS 10.11.
Edit:
It seems to be a problem in Mac OS X. For some reason HFS+ seems not to support hard-links to symlinks.
Best Answer
The filesystem on macOS (HFS+) does not support hard links to symbolic links:
The following would ordinarily create a hard link to a symbolic link, and is even documented in the
ln
manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):You can see by the ref count (1) that no new name was created for
slink
(would have been 2 for bothslink
andhlink
if it had worked). Also,stat
tells us thathlink
is a symbolic link with 1 inode link (not 2):EDIT: Since I was caught using GNU coreutils, here's the tests again with
/bin/ln
on macOS:The hard link is pointing to
file
rather than toslink
.On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in
(notice "2")