How to backup and restore a distro on WSL?

Backing up and restoring WSL distros are easy! Simply exporting the stopped distro into an archive file works pretty well. The archive can be moved on an external disk or cloud share. Restoring a backup is importing back the generated archive.

Moreover we can add multiple instances of the same distro with exporting then importing it. With this we can have for example three different Debian boxes in WSL.

List the available WSL distros

To list our current distros use the following command:

wsl --list --verbose

It will have an output something like this:

NAME STATE VERSION
Debian Running 2
kali-linux Stopped 2

To terminate a distro use the following command:

wsl --terminate kali-linux

The kali-linux is the distro name from the list command above!

Backup a WSL distro

Backing up a WSL distro is with the –export option of the wsl command:

wsl --export kali-linux D:\home_lab\Kali_WSL.tar

The command creates a tar archive of the kali-linux at D:\home_lab and it creates the Kali_WSL.tar file.

Restore a WSL distro

Restoring an image happens with the –import option.

wsl --import kali-linux-restored D:\home_lab\ D:\home_lab\Kali_WSL.tar

The command will restore the saved state of our WSL distro. The name of the new distro is “kali-linux-restored”, it is going to be placed in the D:\home_lab folder and the source archive is the D:\home_lab\Kali_WSL.tar. We can restore a distro into the path of our choice.

If you have a comment or other opinion, visit Tom’s IT Cafe Discord Server and share it!

Leave a comment