How to Back Up and Restore a WSL Distro
A complete walkthrough exporting a WSL distro's entire state to a portable file, and restoring it later — on the same machine after a problem, or on an entirely different machine.
Because a WSL distro is fundamentally just a filesystem tarball plus registration metadata, backing one up completely and restoring it later is straightforward — this walks through doing it properly.
Step 1: identify the distro you want to back up
wsl --list --verbose
Step 2: export the distro to a tar file
wsl --export Ubuntu C:\Backups\ubuntu-backup.tar
This captures the distro’s entire current filesystem state — installed packages, configuration files, home directory contents, everything — into a single portable file.
Step 3: verify the export completed successfully
dir C:\Backups\ubuntu-backup.tar
Check the file size looks reasonable given your distro’s actual disk usage — a suspiciously small file may indicate the export didn’t complete fully.
Step 4: restore to a new distro instance (same or different machine)
wsl --import UbuntuRestored C:\WSL\UbuntuRestored C:\Backups\ubuntu-backup.tar
This creates a genuinely new, independent distro instance from the backup file — on the same machine as a parallel copy, or copied to a different machine entirely and imported there.
Step 5: set the default user for the restored distro
wsl -d UbuntuRestored -u root
# from inside: edit /etc/wsl.conf to set default user, or use:
ubuntu config --default-user yourusername
Export/import preserves the filesystem completely but doesn’t always automatically preserve the original default-user setting — this is worth checking and resetting after import if you land in a root shell unexpectedly.
Step 6: verify the restored distro works as expected
# from inside the restored distro:
ls ~
apt list --installed | head
Confirming your files and installed packages are present as expected verifies the restore actually captured everything you needed.
Step 7: replace an existing distro with a restored backup, if needed
wsl --unregister Ubuntu
wsl --import Ubuntu C:\WSL\Ubuntu C:\Backups\ubuntu-backup.tar
--unregister permanently deletes the current distro’s filesystem — only do this after confirming your backup file is good, ideally by test-importing it under a different temporary name first per Step 4.
Step 8: set up a regular backup schedule for anything you can’t afford to lose
# a scheduled task running wsl --export periodically,
# or simply a manual habit before any risky change
# (a major update, a distro upgrade)
Running an export before attempting anything with real risk of leaving a distro in a broken state — a risky system update, testing an unfamiliar configuration change — gives you a clean rollback point at minimal cost.
Step 9: move a distro to a different drive using the same mechanism
wsl --export Ubuntu D:\temp-export.tar
wsl --unregister Ubuntu
wsl --import Ubuntu D:\WSL\Ubuntu D:\temp-export.tar
Export/import is also the standard way to relocate a distro’s storage to a different physical drive, since the --import command lets you specify exactly where the new virtual disk should be created.
Why this simple mechanism is more reliable than ad hoc file copying
Because export/import operates on the distro as a complete, coherent unit — rather than trying to selectively copy files while leaving out running processes, mounts, or partial state — it produces a genuinely complete, consistent backup every time, without needing to reason carefully about which specific files or directories matter enough to include.