Last active
October 25, 2024 15:42
-
-
Save AleksandrHovhannisyan/5a32aedaf7e71e7af6d401b9af308fa1 to your computer and use it in GitHub Desktop.
Batch script to back up WSL distributions (Windows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
REM List WSL distributions and prompt user to pick one | |
wsl.exe --list | |
set /p distribution="Your WSL distributions are listed above. Enter the name of the distribution to back up: " | |
REM Prompt the user for backup file name | |
set /p outputFile="Enter the path and name of your WSL export file (e.g., E:\wsl-backups\backup.tar): " | |
REM Confirm the action | |
set /p confirmation="Run command 'wsl.exe --export %distribution% %outputFile%'? (y/N): " | |
REM Confirm before running | |
if /i "%confirmation%"=="y" ( | |
wsl.exe --export %distribution% %outputFile% | |
) else ( | |
echo Operation cancelled. | |
) | |
endlocal | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To import it, I just follow this guide: https://murrahjm.github.io/Exporting-WSL-data/
Could probably add it as an option to the script