File copy tools that will preserve hard links at destination

rsync has a --hard-links option:

   -H, --hard-links
          This tells rsync to look for hard-linked files in the source and
          link together the corresponding files on the destination.  With-
          out  this option, hard-linked files in the source are treated as
          though they were separate files.

However, when I tried to copy hard linked files from one volumn to another, I found the hard-links are gone at destination -- each of the hard-linked file have a link count of 1 (instead of >=2).

I copied hard-linked files together in a single rsync command.

Is there anything that I'm missing or rsync can't preserve hard links at destination?


It works here. As @xenoid hinted in their comment above, you never will be able to preserve hard links if the destination filesystem is, say, FAT32, or some other FS that doesn't support hard links.

$ file test /tmp/test
test:      directory
/tmp/test: cannot open `/tmp/test' (No such file or directory)
$ rsync -Ha test /tmp/
$ ls -li test /tmp/test
/tmp/test:
total 3
110995 -rw-------  2 james  james  0 Aug  3 14:40 file1
110996 -rw-------  2 james  james  0 Aug  3 14:40 file2
110994 -rw-------  1 james  james  0 Aug  3 14:40 file3
110995 -rw-------  2 james  james  0 Aug  3 14:40 hard-link-to-file1
110996 -rw-------  2 james  james  0 Aug  3 14:40 hard-link-to-file2

test:
total 3
106655 -rw-------  2 james  james  0 Aug  3 14:40 file1
106656 -rw-------  2 james  james  0 Aug  3 14:40 file2
106657 -rw-------  1 james  james  0 Aug  3 14:40 file3
106655 -rw-------  2 james  james  0 Aug  3 14:40 hard-link-to-file1
106656 -rw-------  2 james  james  0 Aug  3 14:40 hard-link-to-file2