Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup the minecraft saves directory (uses 7-zip)
@ECHO OFF
REM Backup the mincraft saves directory (uses 7-zip)
REM @author ICC 10 Aug 2014
REM @licence MIT
REM usage backs up the user saves directory to the current directory
REM gives the filename .minecraft-saves.[User]-[Computer]-YYYY-MM-DD.bak.7z
REM create date in YYYY-MM-DD format
FOR /f "tokens=1-3 delims=/ " %%a IN ('date /t') DO (SET today=%%c-%%b-%%a)
REM Computer name
SET ip_config_host="Host Name"
FOR /f "usebackq tokens=2 delims=:" %%f IN (`ipconfig /all ^| findstr /c:%ip_config_host%`) DO SET host=%%f
REM trim left spaces
REM @link http://www.dostips.com/DtTipsStringManipulation.php#Snippets.TrimLeftFOR
FOR /f "tokens=* delims= " %%g IN ("%host%") DO SET host=%%g
REM Backup using 7-zip
SET orig_dir=%CD%
C:
CD "%APPDATA%\.minecraft\"
SET file=%orig_dir%\.minecraft-saves.%USERNAME%-%host%-%today%
REM ECHO %file%
7z a -t7z %file%.bak.7z saves
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment