I've found it rather difficult to understand your earlier iterations of this question, so I'm going to restate a simplified version of what I think you mean, along with a corresponding worked example:
Structure
C:\iMazing\Backups\
AL\
files...
BL\
files...
iMazing.Versions\Versions\
AH\
files...
BH\
S:\ExtHDD\APPLE\iMazing.Backups\
AL\
destination files...
BL\
destination files...
iMazing.Versions\Versions\
AH\
destination files...
BH\
destination files...
Requirement is to copy AL\...
and AH\...
from C:
to S:
while maintaining hard links and relative structure.
Worked example
mkdir -p iMazing/Backups/{AL,BL,iMazing.Versions/Versions/{AH,BH}} ExtHDD/APPLE/iMazing.Backups
touch iMazing/Backups/{AL/albackup,BL/blbackup}
touch iMazing/Backups/iMazing.Versions/Versions/{AH/ahbackup,BH/bhbackup}
At this point you can ls -R
or find
to see what I've done. There should be files albackup
, ahbackup
, blbackup
and bhbackup
in the AL
, AH
, BL
, and BH
directories. We're going to copy the AL
and AH
directories to the target:
rsync --dry-run -avHPR iMazing/Backups/./AL iMazing/Backups/./iMazing.Versions/Versions/AH ExtHDD/APPLE/iMazing.Backups/
The -R
(--relative
) flag retains the source path(s) from the /./
marker. In the example this means that iMazing/Backups/
is stripped, and the remainder appended to the destination path.
Once the --dry-run
(-n
) is removed this will copy files and directories from the source AL and AH directories to the target, maintaining internal hard links and structure.
Question solution
Since this is Cygwin you need to use forward slashes and paths starting with /cygdrive/{DriveLetter}
. To maintain links you need to include the -H
flag (--hard-links
).
rsync -aHR /cygdrive/C/iMazing/Backups/./AL /cygdrive/C/iMazing/Backups/./iMazing.Versions/Versions/AH /cygdrive/ExtHDD/APPLE/iMazing.Backups/
You can include the -v
(--verbose
) and/or -P
(--partial --progress
) flags if you want to see what's going on. In this situation rsync
will not bother with its infamous "delta" algorithm or compression (these only work when there are two servers involved in an rsync
client-server configuration across a network). If you could run an instance of rsync
on the server hosting your S: drive that could be far more efficient.
Add --dry-run
to see what would happen without it actually doing anything.
Best Answer
Your idea is right.
Here is a test:
On a different note, its better to use
--delete-after
rather than other similar options i.e.--delete-before
,--delete-delay
,--delete-during
because these options decide which files to delete either before or during the transfer.