Danny Moran

How to backup and restore WSL instances (Windows Subsystem for Linux)

Published April 29, 2023 by Danny Moran

Table of Contents
PAGE CONTENT

Introduction

Learn how to backup and restore WSL (Windows Subsystem for Linux) instances. In this example, I show you how to use the export command to make a .tar backup of a WSL instance, and then how to use the import command to restore that backup file as a new WSL instance.

Video

Find WSL Instances

To get a list of all WSL instances installed on the workstation, run the following command:

wsl -l -v

or

wsl --list --verbose

Exporting or Backing up a WSL instance

Once you’ve got the list of WSL instances, identify the name of the WSL instance you want to backup and run the following command. In the below example, I am backing up the Debian instance, but you can replace debian with the verion of Linux you want to backup.

wsl --export debian c:\wsl\backups\debian.tar

Unregistering a WSL instance

If you want to restore the instance and give it the same name as the original, you need to unregister the original instance. Note, this will fully delete it. In the below example, I am deleting the Debian instance, but you can replace debian with the verion of Linux you want to delete.

wsl --unregister debian

Importing or Restoring a WSL instance

To restore a WSL instance, run the following command. In the below example, I am restoring the Debian instance, but you can replace debian with the verion of Linux you want to backup.

wsl --import Debian c:\wsl\installs\debian c:\wsl\backups\debian.tar