Thursday, December 29, 2022

2023 Vanilla BatchFile ServerStart and Backup

NEW FOR 2023+

UPDATED BACKUP AND SERVER START

The following is a vanilla version that can be easily modified for any MC server. I made some changes from the original one since that one is based a lot on my BLAZEPANEL.  Both ServerStart and backup can be used independently of each other. currently is set to make a max of 7 backups

UPDATES:

  • ServerStart: Server now checks and downloads updated minecraft server for you
  • Backup: Server does not need to be shut down to backup world. The only file that is not backed up is the "server.lock" which is not needed
  • Backup: Default set to 7 days, for slow servers. See line #64 change the "-7" to whatever number (make sure it is a negative).

TODO: Backup to dropbox (or your favorite online site - better than backing up to the same computer). Bookmark 

Install is easy.

  1. Get CURL* for windows. This is used to check for newer MC server updates.
  2. Place both of these batchfiles in your server directory.
  3. Open windows TaskScheduler (or cron) and set a time for the backup script to run.
  4. Run the ServerStart.bat (acts as a restarter as well). Your done.

*I could never get WGET to work.

SERVERSTART.BAT

@echo off
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: :::: S T A R T S E R V E R . B A T                    ::::
:: :::: CONTACT INFO: RSCORPIO64@GMAIL.C                 ::::
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

title Minecraft Server Starter

:: NEED ABSOLUTE PATH TO MINECRAFT SERVER
c:
cd "\mcserver\"

:: LOAD UP THE BATCH FILE
:: start /min "SERVER_BACKUP" backup.bat

:LOAD_SERVER
cls
echo.

echo "   _____            ___________________    _____ _____________________"
echo "  /     \           \_   ___ \______   \  /  _  \\_   _____|__    ___/"
echo " /  \ /  \   ______ /    \  \/|       _/ /  /_\  \|    __)   |    |   "
echo "/    Y    \ /_____/ \     \___|    |   \/    |    \     \    |    |   "
echo "\____|__  /          \______  /____|_  /\____|__  |___  /    |____|   "
echo "        \/                  \/       \/         \/    \/              "
echo "  ________________________________   _______________________          "
echo " /   _____|_   _____|______   \   \ /   |_   _____|______   \         "
echo " \_____  \ |    __)_ |       _/\   Y   / |    __)_ |       _/         "
echo " /        \|        \|    |   \ \     /  |        \|    |   \         "
echo "/_______  /_______  /|____|_  /  \___/  /_______  /|____|_  /         "
echo "        \/        \/        \/                  \/        \/          "
echo "__________ ____ __________    _______  .___ _______    ________       "
echo "\______   \    |   \      \   \      \ |   |\      \  /  _____/       "
echo " |       _/    |   /   |   \  /   |   \|   |/   |   \/   \  ___       "
echo " |    |   \    |  /    |    \/    |    \   /    |    \    \_\  \      "
echo " |____|_  /______/\____|__  /\____|__  /___\____|__  /\______  /      "
echo.

:: next line optional for title display
timeout /t 2

:: GET LATEST SERVER ON EACH LOAD
del server.jar /Q
:: CURL manditory to work
:: https://www.mediafire.com/file/a2tpm3u28k233qt/curl-7.64.1.7z/file
echo.
echo Checking for latest MINECRAFT version
echo ------------------------------------------
curl -O https://piston-data.mojang.com/v1/objects/c9df48efed58511cdd0213c56b9013a7b5c9ac1f/server.jar
echo.
echo.
echo.
echo STARTING SERVER
echo.
echo.
:: LOAD YOUR SERVER HERE
:: ## CHANGE MEMORY REQUIREMENTS HERE AS DESIRED
:: start /b /wait java -server -Xmx4G -Xms1024M -Xmn512M -XX:NewRatio=2 -XX:SoftRefLRUPolicyMSPerMB=2048 -XX:+UseParNewGC -XX:+DisableExplicitGC -Xnoclassgc -oss4M -ss4M -XX:+UseFastAccessorMethods -XX:+UseConcMarkSweepGC -XX:UseSSE=4 -XX:ParallelGCThreads=4 -XX:+AggressiveOpts -cp "server.jar" -jar "server.jar" nogui
start /b /wait "MINECRAFT WATCHDOG" java.exe -Xmx4G -Xms4G -jar server.jar nogui
echo.

:: SYSTEM COMES HERE WHEN THE SERVER STOPS
:: WHAT WE DO HERE IS DO A TIME OUT INCASE THE EXIT WAS INTENTIONAL,
:: IF NOT IT WILL BE TREATED AS A CRASH
:: ALLOW 10 SECOND DELAY,
echo Server stoppped!! Server will reload in 10 seconds,
echo PRESS ANY KEY TO EXIT SERVER
call :controlTimeout 15
if errorlevel 1 (
    GOTO EXIT_SERVER
) else (
    GOTO CRASH
)
exit /b

:controlTimeout
:: TIMEOUT IS A BUILT IN WINDOWS FEATURE
setlocal
start "" /belownormal /b cmd /q /d /c "timeout.exe %~1 /nobreak > nul"
timeout.exe %~1 & tasklist | find "timeout" >nul
if errorlevel 1 ( set "exitCode=0" ) else (
    set "exitCode=1"
    taskkill /f /im timeout.exe 2>nul >nul
)
endlocal & exit /b %exitCode%

:CRASH
:: ADD TO LOG HERE IF CTRL-X WAS NOT PRESED
set this_date = date /t
echo Server Crashed on !this_date! >> crash.log

:: IF NOT, IT MUST HAVE BEEN A CRASH, RELOAD THE SERVER
GOTO LOAD_SERVER

:EXIT_SERVER
del /q server.up
exit 0

 

 

BACKUP.BAT

:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::::              B A C K U P . B A T                 ::::
:: ::::            MINECRAFT SERVER BACKUP               ::::
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: AUTHOR: R.SCORPIO rickscorpio64@gmail.com
:: WEBSITE: https://rustycraftmc.blogspot.com/
@echo off
title "BACKUP SERVER"

:: ----------- EDIT THIS SECTION ------------------------------------
:: mc drive and directory
set mcdrive=c
set mcfolder=c:\MinecraftServer
    :: put the name of the world you want to backup
    set worldname=world
    :: BACKUP folder name
set backupDrive=c
    set backupFolder=c:\MinecraftServer\backups
   
   `if not exist %backupfolder% mkdir %backupfolder%
:: ---- DO NOT EDIT PAST HERE ---------------------------------------
:backup
cls
echo "    _____                                           
echo " __|___  |__  ______  _____  __    _ ______  _____  
echo "|   ___|    ||   ___||     |\  \  //|   ___||     | 
echo " `-.`-.     ||   ___||     \ \  \// |   ___||     \ 
echo "|______|  __||______||__|\__\ \__/  |______||__|\__\
echo "   |_____|                                          
echo "    _____                                           
echo " __|___  |__  ____    ______  __  __  __   _  _____ 
echo "|      >    ||    \  |   ___||  |/ / |  | | ||     |
echo "|     <     ||     \ |   |__ |     \ |  |_| ||    _|
echo "|______>  __||__|\__\|______||__|\__\|______||___|  
echo "   |_____|                                          
                                                
echo.

:: get on the chosen backup drive
%backupDrive%:

:: switch to backup folder
cd "%backupFolder%\"

:: get current time
for /f "tokens=2-4 delims=/ " %%a in ('DATE /T') do (set var=%%c-%%a-%%b)
:: create a dated folder in the backup folder based on the date from above
md %var%

:: start the backup
echo Backing up %worldname% one moment...
xcopy /Y /e /c /exclude:%mcfolder%\exclude.txt "%mcfolder%\%worldname%\*.*" "%backupFolder%\%var%" 
echo Backup completed successfully..
echo.
echo Cleaning up backup folder
:: we dont want anything longer than 7 days of back up. thats plenty.
%backupDrive%:
cd "%backupfolder%\"
FORFILES /S /D -7 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"

:: get back to the minecraft folder
:: some problems testing.. hard code this if vars do not work.
:: %mcdrive%:
c:
cd "%mcfolder%"

Thursday, September 8, 2022

Returning...

Had an issue with the older webhosting, but I forgot to reset the domain here. You should be able to use the blazemcpanel.com again. If I get enough conversation here regarding anything, I'll pick up posting again. For now, most of this is pretty solid. Email or post with any questions


TTYL

Thursday, June 9, 2022

BlueBlock Random Block Placer

 "..now we just need to texture this up" the very phrase from our master builder BlueNerd to make your building look even more natural - brought anguish and trepidation in the minds of noob builders LOL


So I created a simple version that would do it for you. 




Get It here

No installation required. Download and use!