Last active
December 27, 2024 04:41
-
-
Save Bandit/342402dbd5f8307bc8d9c93f67d060c3 to your computer and use it in GitHub Desktop.
Scheduled WSL Backup Batch Script for 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
REM Requires 7zip or NanaZip to be installed | |
@echo off | |
set datestamp=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2% | |
cd C:\WSL-Backup | |
echo "Exporting WSL image..." | |
wsl --export Ubuntu-20.04 .\Ubuntu-20.04.tar | |
echo "Zipping WSL export..." | |
7z a -mx6 .\Ubuntu-20.04-%datestamp%.7z .\Ubuntu-20.04.tar | |
echo "Deleting WSL export..." | |
del /q .\Ubuntu-20.04.tar | |
echo "Deleting older exports..." | |
forfiles /m *.7z /d -1 /c "cmd /c del @path" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment