Skip to content

Instantly share code, notes, and snippets.

@gizzmo
Last active October 6, 2017 05:44
Show Gist options
  • Save gizzmo/2865153 to your computer and use it in GitHub Desktop.
Save gizzmo/2865153 to your computer and use it in GitHub Desktop.
Minecraft saves backup script for windows.
@ECHO OFF
SETLOCAL
::Minecraft backup script
::You need to install 7-Zip first. It can be found here: http://www.7-zip.org/
::Please check the path section first before running!
::---------------------------------------------------------------------------------------------------------------------------------------------------------
::Path section
::Set this variable to your Minecraft path. It should be ok for every Windows 7 OS.
set minecraftpath=%APPDATA%\.minecraft
::Set this Variable to you backup location. By default, it generates a backup folder within the minecraft path.
set backuppath=%APPDATA%\.minecraft\backup
::Set this variable to your 7-Zip location
set zippath="C:\Program Files\7-Zip"
::---------------------------------------------------------------------------------------------------------------------------------------------------------
::Script section
::Check if backup Folder exists
IF NOT EXIST %backuppath%\ mkdir %backuppath%
::Check for 7zip
IF NOT EXIST %zippath%\7z.exe (
echo 7-zip was not found! Please download it from http://7-zip.org/
goto EOF
)
::Getting current date and time information
set year=%date:~-4%
set month=%date:~-10,2%
set day=%date:~-7,2%
set hour=%time:~-11,2%
set minute=%time:~-8,2%
set second=%time:~-5,2%
::Fix hour having a space
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo Starting backup...
::Start of the filenames
set filename=%year%-%month%-%day% %hour%-%minute%
::Create the log file header
echo %year%-%month%-%day% @ %hour%:%minute%:%second% >> "%backuppath%\%filename%.log"
echo. >> "%backuppath%\%filename%.log"
::Make the backup 7zip and pipe the output to the log
%zippath%\7z.exe a -t7z -mx9 "%backuppath%\%filename%.7z" %minecraftpath%\saves\ >> "%backuppath%\%filename%".log
echo Backup done!
:EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment