Skip to content
Follow
Ubuntu Linux Windows

How to Back Up and Restore Linux on WSL

Richard
Written by
Richard
Jan 21, 2022 Updated Aug 13, 2026 2 min read
How to Enable or Disable Phone Link in Windows 11
How to Enable or Disable Phone Link in Windows 11

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.

⚡ Quick Answer

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.

Windows 11 Command Prompt running as administrator for WSL backup
windows 11 command prompt administrator

2. List your installed distributions:

💻Code
wsl.exe --list

Exporting your WSL distribution

Exporting a WSL distribution creates a backup file of the Linux system using a dedicated command.

💻Code
wsl --export Ubuntu-20.04 C:\backup\my-linux-backup.tar
💡Pro Tip
Compressing the resulting .tar file using tools like 7-Zip saves significant disk space.

Importing 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.

💻Code
wsl --import Ubuntu-20.04 C:\Users\genericuser\Ubuntu C:\backup\my-linux-backup.tar

Advanced 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?

Was this helpful?
Richard

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.

📚 Related Tutorials

How to Access Command Prompt in Windows 11
Windows How to Access Command Prompt in Windows 11
How to Access Linux Files on Windows 11 Using WSL
Windows How to Access Linux Files on Windows 11 Using WSL
How to Install Windows Subsystem for Linux (WSL) on Windows 11
Ubuntu Linux How to Install Windows Subsystem for Linux (WSL) on Windows 11
How to Uninstall Windows Subsystem for Linux (WSL) in Windows 11
Ubuntu Linux How to Uninstall Windows Subsystem for Linux (WSL) in Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

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