How to Back Up and Restore a WSL Distro

🐧Part of the WSL Complete Guide, every Windows Subsystem for Linux post on this site, organised by task.
The short answer

wsl --export <Distro> backup.tar to back up, wsl --import <NewName> <Folder> backup.tar to restore.

Before you experiment with a distribution, upgrade it, or hand a working environment to a colleague, it is worth knowing that the whole thing exports to a single file. It is the closest WSL has to a snapshot.

Back It Up

# stop it first so nothing is mid-write
wsl --terminate Ubuntu

# export the whole distribution to a tar file
wsl --export Ubuntu D:\Backups\ubuntu-2026-08-13.tar

The file is the entire Linux filesystem, so expect it to be large. Exporting a distribution that has been in use for a while can easily produce several gigabytes.

Restore It

# restore into a new folder, under any name you like
wsl --import Ubuntu-Restored D:\WSL\ubuntu-restored D:\Backups\ubuntu-2026-08-13.tar

# confirm it is there
wsl -l -v

Cloning Is the Same Trick

Because the import name is arbitrary, export and import is also how you clone a working environment to experiment safely:

wsl --export Ubuntu D:\Temp\base.tar
wsl --import Ubuntu-Test D:\WSL\ubuntu-test D:\Temp\base.tar
An imported distribution starts as root. The default user is not carried in the tar file, so set it afterwards with wsl --manage Ubuntu-Restored --set-default-user <name>. The account itself does come across, it is only the default that resets.

Worth knowing too: this backs up the Linux filesystem, not your Windows files. Anything you keep under /mnt/c lives on Windows and is not in the tar.

Related


If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.


Comments

Leave a Reply

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

Looking for SQL Server?

This site started as a SQL Server blog in 2017 and the archive is still here. The new SQL Server writing, and all the scripts, moved to a site of their own.

sqldba.blogScripts, error library, wait types, SSMS
Browse by topic