For those who don’t know about WSL, here’s an overview: Windows Subsystem for Linux that lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot. You can use WSL to run Linux within Windows without the need for additional hardware or a dedicated virtual machine environment. Using its export and import feature allows you to store your Linux machine securely and restore it in an event that the original is corrupted or not functioning properly. One caveat when using the export and import method is that the Linux machine will lose its integration with the Start menu, and no longer appear as an item in the Apps & features settings after you import it. But all other functionality will remain. Below is how to use the export and import feature with WSL.

How to backup and restore Linux machine on WSL

As mentioned above, when users use WSL, they can back up (export) Linux or restore (input) onto another WSL system easily using the wsl.exe –export and –import command options. To backup Linux in WSL, go to the Start menu in Windows, then search and open the Command Prompt as administrator. Once the command prompt opens, you can list all available Linux OS in your WSL environment. Now to backup a Linux OS named (Ubuntu-20.04), use the command format below: Change the Linux machine name to the one in your environment, and also change the destination path to where you want to store the backup file. In the example above, the destination backup location is in the C:\Windows folder. Once the file is backed up, you can restore the machine on the same WSL host or another Windows host running WSL. To restore, use the command format below. Change the name of the Linux machine as well as the location to restore the Linux machine. By default, Windows stores Linux machines in the following location: C:\Users<username>\AppData\Local\Packages If you want to restore the machine to the default location, simply use the default location instead. That should do it! However, when you export and restore a Linux machine using the steps above, it won’t have the same integration as installing the distros from the Microsoft Store. It won’t register in the Start menu, or appear as an app on the Apps & features settings page. Conclusion: This post showed you how to back up and restore a Linux machine running in a WSL environment on a Windows host. If you find any error above or have something to add, please use the comment form below.