I have a directory with huge files and a number of directories, that have hardlinks on these huge files. How do I copy files from one filesystem to the other and preserve hard links?
tar is preserving links (both symbolic and hard ones). To copy between filesystems, you would use it that way:
tar -cf - -C srcdir . | tar -xpf - -C destdir
See the tar man page for more details (this is where this example is actually coming from).
rsync can preserve hard-links with the -H option.
$ cp -r --preserve=links src dst
preserve the specified attributes (default: mode,ownership,timestamps),
if possible additional attributes: context, links, xattr, all
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2 years ago