Home > Common Problem > body text

How to back up and restore Windows Subsystem for Linux (WSL) distributions

WBOY
Release: 2023-04-18 19:34:03
forward
2329 people have browsed it

How to Backup Windows Subsystem for Linux (WSL) Distro

How to back up and restore Windows Subsystem for Linux (WSL) distributions

Since WSL is not Linux running on bare metal, we don’t need to do that within the distribution itself Perform any action to initiate a backup. Instead, the action is run entirely from PowerShell.

First, run the command wsl -l -v in PowerShell to print a list of all currently installed Linux distributions. It is important to know the exact name of the where the backup was created. For example, you might have "Ubuntu-22.04" instead of just "Ubuntu".

Once you have this information, the following command will export a full backup of the selected distribution. Before entering, cd into the directory where you want to save the backup. Any directory you put on the command line is the directory your backups will be saved to by default.

wsl --export (distribution) (filename.tar)
Copy after login

For example, a backup of Debian would look like this:

wsl --export Debian debianbackup.tar
Copy after login

Alternatively, you can specify the file location and filename during the export process instead of using cd into the correct directory. For example:

wsl --export Ubuntu c:\users\richard\desktop\ubuntumay27.tar
Copy after login

This is the backup process. The file you create now can be used on the same PC or another PC to set up an exact copy of your Linux distribution. You can do this using the import command in Powershell.

How to Import a WSL Distribution from a Backup

How to back up and restore Windows Subsystem for Linux (WSL) distributions

If you are exporting, there is a good chance that you will want to be able to use that backup distribution at some point . This is done in WSL using the import command.

It's a little longer than the export command because you need to specify where you want to install it and what files you want to use. The import command follows this template:

wsl --import (distribution) (install location) (file location and filename)
Copy after login

So using one of the example exports above, you'll end up with something like this:

wsl --import Ubuntu c:\wsl c:\users\richard\desktop\ubuntumay27.tar
Copy after login

After a few moments, your distribution will be installed and ready to go . The beauty of using export and import is that you can set up the same environment on multiple machines in a short period of time. Your user and password will be retained, as will anything you installed via your package manager.

If you want to confirm that it is installed correctly before closing the PowerShell window, just run wsl -l -v again and you should see the newly imported distribution.

The above is the detailed content of How to back up and restore Windows Subsystem for Linux (WSL) distributions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yundongfang.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template