How-Tos

How-To: Move Your Linux Home Folder to a New Machine With rsync

Leave a comment

Microsoft just dropped PC-to-PC migration on Windows. On Linux, moving to a new box is still one command. Here’s how I do it through an external drive, no cloud account required.

1. Copy to the drive

Plug in the drive and find where it’s mounted (lsblk). Then:

rsync -aHAX --info=progress2 \
  --exclude='.cache/' --exclude='Downloads/*.iso' \
  ~/ /run/media/$USER/backup/home/
  • -a keeps permissions, times and symlinks.
  • -H -A -X keep hard links, ACLs and extended attributes.
  • The trailing slash on ~/ copies the contents, not the folder itself.

2. Dry run first

Add -n (dry run) to any rsync command to see what it would do before it does it.

3. Restore on the new machine

rsync -aHAX --info=progress2 /run/media/$USER/backup/home/ ~/

4. Run it again

rsync only copies what changed, so a second pass right before you switch over is quick. Don’t add --delete unless you’re sure, because it removes files on the destination.

Tips

  • Keep SSH keys and secrets on an encrypted drive, and check their permissions after the copy.
  • Reinstall apps from your package manager instead of copying them.

Isolate it: try new software in a disposable VM or spare machine first, with a backup you can roll back to.

God Bless, and Happy hacking!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.