How to back up a Linux distro in WSL

Home / Web development / How to back up a Linux distro in WSL

If you have been using WSL to run a Linux virtual machine on your Windows 10/11 computer, then you will know that it is a good idea to make a backup of your distro in case you might need it in the future if something goes wrong. Luckily, Windows allows us to do this backup in a simple way.

Today we are going to look at the process of backing up your Linux distribution to the location of your choice on Windows 10/11 with the CLI tool for WSL, using the command prompt or PowerShell, whichever you prefer.

How to back up the Linux distribution to WSL on Windows 10/11

  • Step 1: Open the Start menu on your Windows 11 computer.
  • Step 2: Search for "Command Prompt" or "PowerShell". In the search results, right-click on the desired application and select the "Run as administrator" option.
  • Step 3: In the console, enter the following command which will show you the list of Linux distros available on the device.
wsl --list
wsl --list
  • Step 4: Finally, enter the following command to create a backup copy of the desired distribution:
wsl --export <nombre-de-la-distro> <nombre-del-archivo-de-backup>.tar
wsl --export

Be sure to change the "dist-name" to the actual name of the Linux distribution on your system and change the "backup-file-name.tar" to the location and file name where you want to store the backup. If you do not specify a location, the backup file will be stored on the system drive. The process may take a while, depending on the disk size of the distribution.

And that's it. If you have followed the steps correctly (and have been patient), you will have successfully exported the WSL Linux distro virtual machine.

This backup can now be imported to a new distro within the same system or to some other computer, and can also be shared with other people.

Click on the following link if you want to know how to import a Linux distribution for WSL

<i class="fa fa-angle-up" aria-hidden="true"></i>