How to migrate data from a UGREEN NAS to TrueNAS SCALE with rsync
Copy terabytes from a UGREEN NAS to TrueNAS with rsync in tmux, so a lost connection does not start it again.
Before you start
- Shell access on the machine that copies the data
rsyncandtmuxavailable on it- SSH access to the source machine
- Enough free space on the destination
Your values
Fill these in and every command below updates to match. Nothing is sent anywhere.
Run this at your own risk. These steps worked on my hardware; yours may differ. Take a backup first, read each command before running it, and see the disclaimer.
To move from a UGREEN NAS (running UGOS) to TrueNAS SCALE, you copy everything over the network. That copy can take a whole night or longer.
If you start a copy of several terabytes with rsync over SSH and close the laptop, you come back to a closed session and a half-copied dataset. The copy depended on the SSH connection, and the connection did not last the night.
Nothing here only works for UGREEN or TrueNAS. The same two habits work for any move between two NAS systems that both give you a shell: Synology, QNAP, unRAID, or a normal Linux machine.
The fix is two simple habits that take about thirty seconds.
Run it inside a named tmux session
tmux keeps the shell running on the remote machine, even when your connection ends. You can detach, close the laptop, connect again tomorrow, and attach again.
Give the session a name. In three days you will not remember which unnamed session was the important one.
tmux new -s nas-migrationIf the session already exists, attach to it instead:
tmux attach -t nas-migrationDetach with Ctrl+b then d. The transfer keeps running.
Start the transfer with resume enabled
rsync -aHAX --partial --info=progress2 \
admin@nas-old.example.lan:/volume1/Shared/ \
/mnt/tank/Shared/What each option does, because they are important:
-aarchive mode: copies folders and keeps permissions, times, symlinks and ownership-Hkeeps hard links, which archive mode does not do-Akeeps ACLs,-Xkeeps extended attributes--partialkeeps files that were only partly copied, so a stopped run continues instead of starting that file again--info=progress2shows one progress line for everything, not a line per file
Without --partial, if the copy stops in the middle of a 90 GB file, all 90 GB are lost and must be copied again.
The slash at the end of the source is important. src/ copies the contents of src into the destination. src copies the folder itself into the destination. If you get this wrong, you end up with /mnt/tank/Shared/src/src.
Watch it, or do not
tmux attach -t nas-migration 1.61T 47% 112.43MB/s 4:32:11Run it again when it finishes
Always run the same command a second time. The first run took hours, and files changed while it ran. The second run only copies the differences, so it is quick. It also shows you that the first run really finished.
rsync -aHAX --partial --info=progress2 \
admin@nas-old.example.lan:/volume1/Shared/ \
/mnt/tank/Shared/Check before you trust it
--dry-run with --itemize-changes shows what a third run would do, without doing it. Ideally the list is empty.
rsync -aHAXn --itemize-changes \
admin@nas-old.example.lan:/volume1/Shared/ \
/mnt/tank/Shared/ | head -50Each line that starts with >f is a file it still wants to copy. An empty result means both sides are the same.
Only now consider --delete
--delete deletes files at the destination that no longer exist at the source. It is the right option to keep an exact copy up to date. But it is dangerous if the source is only partly mounted, because then it deletes files that are not really gone.
Never use it on the first run. Never use it before you have run the --dry-run above and read the result.
rsync -aHAX --delete --info=progress2 \
admin@nas-old.example.lan:/volume1/Shared/ \
/mnt/tank/Shared/Leave the session behind
tmux kill-session -t nas-migrationDid this guide work for you?
Thank you! That helps me keep this guide right.