Working Syntax for Rsync Copy of a set of 2 or more Hard-linked Folder Trees while maintaining this specific archive structure?
PS: Would this be a better fit in SO or SU SE?
Template of Current/ Example Folder Structure:
Base Folder (Source):
C:\iMazing
\Backups
\{device A UDID} // Last backup of Device A (AL)
\{device B UDID} // Last backup of Device B (BL)
\iMazing.Versions
\Versions
\{device A UDID} // Backup history of Device A (AL)
\{device B UDID} // Backup history of Device B (BH)
Base Folder (Destination):
S:\ExtHDD\APPLE\iMazing.Backups
\{device A UDID} // Last backup of Device A (AL)
\{device B UDID} // Last backup of Device B (BL)
\iMazing.Versions
\Versions
\{device A UDID} // Backup history of Device A (AH)
\{device B UDID} // Backup history of Device B (BH)
Folder Trees under Folders with UDID Names
- AL : {device A UDID} // Last backup of Device A
- AH : {device A UDID} // Backup history of Device A
- AL & AH Form a SINGLE 2 SET with Hard Links in between.
- We'd like to work INDIVIDUAL SET at a time
How to use Rsync (preferable via Cygwin RSync or one of mentioned Windows variations) to :
- Copy a Hard Linked INDIVIDUAL SET e.g. {AL + AH} from C drive to S drive while
- Preserving Hard Links
- Maintain the Sub-tree folder structure
- Without causing issues on Windows or its NTFS Folder & File structure
Also:
- Can we do only an INDIVIDUAL SET at a time (one single RSync command) or multiple SPECIFIED SETs?
- Typically we have 2 SETs, how would commandline for Rsync change if it was a 3 SET (SET with 3 HL folders) within a structure
A Real/ Actual Example with UDID Folder name:
- XL & XH which are Hard Linked folder trees, together make up a SET.
Base Folder (Source):
C:\Users\UserName\AppData\Roaming\iMazing\Backups
\f22ebcffcdd1b508d3f7564431a9db98d69208ef-20190414-170122 //..(XL)
\iMazing.Versions
\Versions
\f22ebcffcdd1b508d3f7564431a9db98d69208ef-20190414-170122 //..(XH)
Reference list of Tools for Hard Link preserving Copying:
https://superuser.com/questions/997190/copy-to-another-ntfs-disk-and-preserve-hard-links/
- Rsync variations under Windows
- (Several *Nix & Windows: Cygwin variations, CW RSync, Delta Copy/ Syncrify/ Synaman, GRsync, RsyncBackup, Rsync.exe pkg, Rclone, AcroSync, YInterSync)
- ln.exe – command line hardlinks – http://schinagl.priv.at/nt/ln/ln.html (Win)
Best Answer
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
Requirement is to copy
AL\...
andAH\...
fromC:
toS:
while maintaining hard links and relative structure.Worked example
At this point you can
ls -R
orfind
to see what I've done. There should be filesalbackup
,ahbackup
,blbackup
andbhbackup
in theAL
,AH
,BL
, andBH
directories. We're going to copy theAL
andAH
directories to the target:The
-R
(--relative
) flag retains the source path(s) from the/./
marker. In the example this means thatiMazing/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
).You can include the
-v
(--verbose
) and/or-P
(--partial --progress
) flags if you want to see what's going on. In this situationrsync
will not bother with its infamous "delta" algorithm or compression (these only work when there are two servers involved in anrsync
client-server configuration across a network). If you could run an instance ofrsync
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.