rsync is a practical utility for synchronizing files and directories and is especially useful for data migration on TrueNAS. It copies only what changed after the initial transfer and provides options for validation.
Why rsync Is Better Than cp for Large Transfers
- Delta transfer:
rsynctransfers only the differences between source and destination files after the initial copy. - Resume capability: If a transfer is interrupted, rerunning the command avoids copying everything again.
- Robust error handling:
rsyncis designed for reliable large transfers. - Integrity verification: Options such as
--checksumprovide stronger guarantees than a plaincpworkflow.
How to Use rsync on TrueNAS
You can execute rsync directly from the TrueNAS shell to control data transfer between storage devices.
Tip: The TrueNAS web shell is not ideal for long-running transfers because sessions can disconnect. SSH from your main PC is usually more reliable.
Example Command
rsync -avh --info=progress2 --no-compress --checksum "/from_dir" "/to_dir"
Option Breakdown
-a: Archive mode for recursive copying and preserving important file metadata.-v: Verbose output.-h: Human-readable sizes.--info=progress2: Shows overall progress and estimated time remaining.--no-compress: Avoids unnecessary compression for local transfers.--checksum: Verifies file integrity using checksums instead of relying only on timestamps and sizes."/from_dir": Source directory. The trailing slash choice affects whether contents or the directory itself are copied."/to_dir": Destination directory.
Other Helpful Flags
--remove-source-files: Deletes source files after a successful transfer. Use carefully.--delete: Deletes destination files that are not present in the source. Use carefully.--dry-runor-n: Simulates the transfer without making changes.--exclude='PATTERN': Skips matching files or directories.
This gives you a more robust and verifiable workflow for migrating data on TrueNAS.