Skip to content

Instantly share code, notes, and snippets.

@AHrubik
Forked from gizzmo/minecraft_backup.bat
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AHrubik/9728335 to your computer and use it in GitHub Desktop.
Save AHrubik/9728335 to your computer and use it in GitHub Desktop.
Backup batch for non Forge Minecraft
@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=H:\Vanilla
::Set this Variable to you backup location. By default, it generates a backup folder within the minecraft path.
set backuppath=D:\Backup\Vanilla
::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%\ >> "%backuppath%\%filename%".log
echo Backup done!
::Cleaning up Old Backups - Everything over 24 hours old goes kaput!
forfiles -p "D:\Backup\Vanilla" -s -m *.* /D -1 /C "cmd /c del @path"
echo Cleanup done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment