Skip to content

Instantly share code, notes, and snippets.

@jeroensmink98
Created April 19, 2023 20:31
Show Gist options
  • Save jeroensmink98/865f23175148efcf8613cd79d6715799 to your computer and use it in GitHub Desktop.
Save jeroensmink98/865f23175148efcf8613cd79d6715799 to your computer and use it in GitHub Desktop.
Create an export of your favorite WSL2 Distro
# Set the path to your desired output folder
$outputFolder = "C:\WSL_Backup"
# Create the output folder if it doesn't exist
if (!(Test-Path $outputFolder)) {
New-Item -ItemType Directory -Path $outputFolder | Out-Null
}
# Get the current date and time in a format suitable for filenames
$date = Get-Date -Format "yyyy-MM-dd_HHmmss"
# Set the name of the WSL installation you want to export
$distroName = "Ubuntu-22.04"
# Set the filename of the output file
$outputFile = "$outputFolder\$distroName-$date.tar"
# Export the WSL installation to a .tar file
wsl --export $distroName $outputFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment