Ubuntu Linux Windows

How to Back Up and Restore Linux on WSL

Richard
Written by
Richard
Jan 21, 2022 Updated Apr 29, 2026 2 min read
How to Back Up and Restore Linux on WSL

This guide explains how to backup restore Linux WSL environments effectively. By using the built-in export and import features, you can protect your WSL 2 filesystem and recover your work if something goes wrong.

Why back up your Linux environment?

Why: WSL lets you run Linux tools inside Windows. If your Linux setup gets corrupted, having a backup allows you to recover your work quickly without starting from scratch. It also helps with WSL 2 migration or moving your instance to a faster drive.

What happens when you are done?

What happens: Once you import a backup, your Linux distribution will function normally. However, it will no longer be linked to the Microsoft Store Start menu. It will not appear in your Windows Apps & features list, but your files and programs remain fully accessible.

How to back up and restore Linux on WSL

Note: You must run these commands in Windows PowerShell or Command Prompt with admin privileges.

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

2. List your installed distributions:

💻Code
wsl.exe --list

Exporting your WSL distribution

To export WSL distribution, use the following command. This creates a tar archive of your system.

💻Code
wsl --export Ubuntu-20.04 C:\backup\my-linux-backup.tar

Pro Tip: You can compress the resulting .tar file using tools like 7-Zip to save significant disk space.

Importing your WSL distribution

To restore or move your instance, use the import command. This creates a new vhdx file in your chosen directory.

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

Advanced Troubleshooting and Automation

If you need to move your instance to a different drive, simply export it, wsl –unregister the old one, and import it to the new path. For automation, you can save the export command in a .ps1 script and use Windows Task Scheduler to run it daily.

Summary

Backing up your WSL environment is essential for WSL data recovery. By using wsl --export and wsl --import, you can easily manage your instances, move them to new drives, or duplicate your setup. While these methods require admin privileges, they provide a reliable way to keep your Linux environment safe.

Can I back up a running WSL instance?

It is highly recommended to shut down your WSL instance before backing it up to ensure data consistency. Use the command ‘wsl –shutdown’ in PowerShell before running your export command to prevent file corruption or incomplete snapshots of your 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 does not include files stored on your Windows drives that you access via the /mnt/c path. You must back up those Windows files separately using standard backup software.

Was this guide 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.

2463 articles → Twitter

📚 Related Tutorials

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 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 Uninstall Windows Subsystem for Linux (WSL) in Windows 11
Ubuntu Linux How to Uninstall Windows Subsystem for Linux (WSL) in Windows 11

Leave a Reply

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