Copy to another NTFS disk and preserve hard links

Tool To Copy Hard Links Across Separate Disk Partitions

LN - Command Line Hardlinks

Example Command: ln --copy x:\dir\dir2 y:\dir\newdir

In the above example the directories and files below x:\dir\dir2 are copied to y:\dir\newdir, and all hardlinks/junctions/symbolic links within x:\dir\dir2 are copied/tied to their new locations under y:\dir\newdir.


Download

enter image description here

Basic Instructions

  • Download the software for your CPU architecture from the applicable zip file, as well as the vcredist (Visual C++ Redistributable) and install it.
  • Then just extract the files and folders from the zip file to a new folder somewhere (.e.g C:\Temp).
  • In command prompt, change to that [directory] folder (e.g. cd /d C:\Temp) and then run the needed commands for your drive locations as the above example command shows.

Note: Running ln --help shows help detail but the above command example is supposed to copy the hard links per the documentation.


Potentially Relevant Functions

  • Smart Mirror
  • Clone
  • Smart Copy

Other Notes

It appears hard links are locked to the same disk partition for their file pointers, and cannot be used across multiple partitions. Also, hard links on NTFS partitions are part of the Master File Table records—or attributes for the counts at least—so copying these to an existing disk that has it's own MFT could be a problem if you don't clone byte-for-byte at the partition level at least.


The command-line utility rsync does what you ask.

Presuming your old data is on location A, and your new data is on B, do the following:

rsync -ahPruvz --hard-links A B

Quoting from rsync manual:

This tells rsync to look for hard-linked files in the source and link together the corresponding files on the destination.

How to obtain rsync and use it? There are 2 easy alternatives for Windows:

First alternative: use cygwin. It's a windows software. Install it, add rsync at the step of selecting packages. Leave everything else defaulted. After you install it, use its shell to type in the command. If you want, you may use the full path, /usr/bin/rsync instead of just rsync. If you want to access Windows drives, use paths like "/cygwin/drives" and always try to auto-complete using TAB.

Second alternative: if it's a desktop computer, use a live GNU/Linux distribution. Prepare a live USB image, boot from it, mount the desired disks and invoke rsync. If the live image does not have rsync, install it. (apt-get install rsync in Debian and its derivatives.) If you're not yet experienced with the Linux ecosystem, cygwin could be easier.


Try looking into rsync for windows. Since rsync has an option to preserve hardlinks (flag -H, --hard-links) it should do the job (source: https://download.samba.org/pub/rsync/rsync.html).

You could try looking into something like cwRsync: https://www.itefix.net/cwrsync# this one has GUI.

cwRsync is a packaging of Rsync for Windows with a client GUI. You can use cwRsync for fast remote file backup and synchronization.