Rsync -avzHP follows hardlinks instead of copying them as hardlinks
The rsync
command's -H
(or --hard-links
) option will, in theory, do what you are trying to accomplish, which is, in brief: to create a copy of your filesystem that preserves the hard linked structure of the original. As I mentioned in my answer to another similar question, this option is doomed to fail once your source filesystem grows beyond a certain threshold of hard link complexity.
The precise location of that threshold may depend on your RAM and the total number of hard links (and probably a number of other things), but I have found that there's no point in trying to define it precisely. What really matters is that the threshold is all-too-easy to cross in real-world situations, and you won't know that you have crossed it, until the day comes that you try to run an rsync -aH
or a cp -a
that struggles and eventually fails.
What I recommend is this: Copy your heavily hard linked filesystem as one unit, not as files. That is, copy the entire filesystem partition as one big blob. There are a number of tools available to do this, but the most ubiquitous is dd
.
With stock firmware, your QNAP NAS should have dd
built in, as well as fdisk
. With fdisk
, create a partition on the destination drive that is at least as large as the source partition. Then, use dd
to create an exact copy of your source partition on the newly created destination partition.
While the dd
copy is in progress, you must ensure that nothing changes in the source filesystem, lest you end up with a corrupted copy on the destination. One way to do that is to umount
the source before starting the copying process; another way is to mount the source in read-only mode.