How to Back Up and Restore Linux on WSL
Backing up and restoring Linux on WSL (Windows Subsystem for Linux) saves your entire Linux setup into a single file so you never lose your files and apps. WSL runs Linux right inside Windows 10 and Windows 11, and exporting your setup creates a safe copy on your hard drive.
You can use the built-in Windows command prompt to save an exact copy of your distribution, like Ubuntu 22.04 LTS, as a .tar archive. When things break or you switch to a new PC, importing that file brings back all your custom settings and personal files in just a few minutes.
Back up your Linux on WSL distribution by running `wsl –export ` in an administrator PowerShell. Restore it using `wsl –import `. These commands create and restore a portable tar archive of your Linux environment.
Why back up your Linux environment?
Protecting the Linux environment prevents data loss from unexpected system issues.
What happens when you are done?
Once imported, the system functions normally, though restored instances will not appear in the Windows Start menu or apps list automatically.
How to back up and restore Linux on WSL
Safeguarding files or migrating them to another machine requires Windows PowerShell. Running PowerShell with administrator privileges gives the terminal full permission to read and export every Linux file.
1. Open the Start menu , search for PowerShell, and select Run as administrator. Learn how to run as administrator here.

2. List your installed distributions:
wsl.exe --listExporting your WSL distribution
Exporting a WSL distribution creates a backup file of the Linux system using a dedicated command.
wsl --export Ubuntu-20.04 C:\backup\my-linux-backup.tarImporting your WSL distribution
Restoring or moving an instance relies on the import command. This process generates a new .vhdx file (a virtual hard disk format used by Windows) in the chosen folder.
wsl --import Ubuntu-20.04 C:\Users\genericuser\Ubuntu C:\backup\my-linux-backup.tarAdvanced Troubleshooting and Automation
Moving an instance to a different drive requires exporting it, unregistering the old one with wsl --unregister, and importing it to the new path. Automated backups involve saving the export command within a .ps1 script and executing it daily through Windows Task Scheduler.
Summary
Backing up and restoring a Linux WSL setup remains vital for data safety, streamlining system migrations and troubleshooting.
Can I back up a running WSL instance?
Shutting down the WSL instance beforehand ensures data consistency. Running the command 'wsl --shutdown' in PowerShell prior to an export prevents file corruption or incomplete snapshots of the Linux environment.
Does wsl --export include my Windows-side files?
No, the export command only captures the Linux filesystem contained within the WSL virtual disk. It excludes files stored on Windows drives accessed via the /mnt/c path, which require separate backups using standard software.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!