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!

Saturday, July 4, 2020

BATCH FILE RE-STARTER & BACKUP

I run an elaborate batch-file re-starter. It monitors the server for functionality, if it crashes, it will auto reboot, with an option to cancel it. This file works with the backup.bat file. Both of these are modified versions of my BLAZE batch files.

Please do not post this script anywhere else without credit, permission, or linkback


STARTSERVER.BAT FILE

@echo off
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: :::: B L A Z E  S T A R T S E R  E R . B A T          ::::
:: :::: THIS MINECRAFT SERVER RE-STARTER SHOULD BE USED  ::::
:: :::: IN CONJUNCTION WITH THE BLAZE BACKUP.BAT         ::::
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

title Minecraft Server Starter

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

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

:LOAD_SERVER
cls
echo   @@@@@@ @@@@@@@@ @@@@@@@  @@@  @@@ @@@@@@@@ @@@@@@@      
echo  !@@     @@!      @@!  @@@ @@!  @@@ @@!      @@!  @@@     
echo   !@@!!  @!!!:!   @!@!!@!  @!@  !@! @!!!:!   @!@!!@!      
echo      !:! !!:      !!: :!!   !: .:!  !!:      !!: :!!      
echo  ::.: :  : :: :::  :   : :    ::    : :: :::  :   : :     
echo.                                                          
echo  @@@@@@@  @@@  @@@ @@@  @@@ @@@  @@@ @@@ @@@  @@@  @@@@@@@
echo  @@!  @@@ @@!  @@@ @@!@!@@@ @@!@!@@@ @@! @@!@!@@@ !@@     
echo  @!@!!@!  @!@  !@! @!@@!!@! @!@@!!@! !!@ @!@@!!@! !@! @!@!@
echo  !!: :!!  !!:  !!! !!:  !!! !!:  !!! !!: !!:  !!! :!!   !!:
echo   :   : :  :.:: :  ::    :  ::    :  :   ::    :   :: :: :
echo.                                                                           

:: LET BACKUP BATCH KNOW THE SERVER IS UP (SORTA)
echo "server up" > server.up

:: LOAD YOUR SERVER HERE
start /wait "BLAZEMCPANEL" java.exe -Xmx4048M -Xms4048M  -jar minecraft_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
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


Please do not post this script anywhere else without credit, permission, or linkback


BACKUP.BAT
REQUIRED: 7z.exe & 7z.dll in your MC Server Directory
@echo off

:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::::         B L A Z E  B A C K U P . B A T           ::::
:: :::: THIS MINECRAFT SERVER RE-STARTER SHOULD BE USED  ::::
:: :::: IN CONJUNCTION WITH THE BLAZE STARTUP.BAT        ::::
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: AUTHOR: R.SCORPIO rickscorpio64@gmail.com
:: WEBSITE: https://rustycraftmc.blogspot.com/

setlocal EnableDelayedExpansion
title "BACKUP SERVER"

:: SERVER BACKUP SECTION
:: I do not use a "date" format, as the files when created already have a timestamp
:: which you can see in the file explorer




:: ----------- EDIT THIS SECTION ------------------------------------

    :: put the name of the world you want to backup
    set worldname=world
    :: 600 = 10min, 900 = 15min, 1200 = 20min (add 300 seconds/5min)
    set interval=300
    :: BACKUP folder name
    set backupFolder=backups
    :: Set number of backups before counter reset. 5-10 is good for a small server
    set max_backups=25
    :: Starting counter. Really no reason to change this. Used for routine below
    set backupcount=1
   
:: ---- DO NOT EDIT PAST HERE ---------------------------------------
:backup
cls
echo "    _____                                           
echo " __|___  |__  ______  _____  __    _ ______  _____  
echo "|   ___|    ||   ___||     |\  \  //|   ___||     | 
echo " `-.`-.     ||   ___||     \ \  \// |   ___||     \ 
echo "|______|  __||______||__|\__\ \__/  |______||__|\__\
echo "   |_____|                                          
echo "    _____                                           
echo " __|___  |__  ____    ______  __  __  __   _  _____ 
echo "|      >    ||    \  |   ___||  |/ / |  | | ||     |
echo "|     <     ||     \ |   |__ |     \ |  |_| ||    _|
echo "|______>  __||__|\__\|______||__|\__\|______||___|  
echo "   |_____|                                          
                                                
echo.
:: if server.up exist, we can keep doing backups
:: this is a method used so backups do not continue if
:: the server is down.

echo Checking archive count
for %%x in ("%backupFolder%\*.7z") do (set /a "backupcount=!backupcount!+1")
if !backupcount! gtr %max_backups% ( set backupcount=1 )   

echo Copying world to backup folder.
xcopy "%worldname%\*.*" %backupFolder% /s /e /q /y

:: regarding the "^^" - I am using the setlocal EnableDelayedExpansion,
:: this makes the "!" has a special meaning and overrides the 7z ! symbol
:: the ^^ escapes the "!" so it can be used correctly
echo Archiving backup # !backupcount!
echo Processing: %backupFolder%\serverBackup_%backupcount%.7z %backupFolder%
7z a  %backupFolder%\serverBackup_%backupcount%.7z %backupFolder% -xr^^!*.7z > nul
echo DONE!
:: We need to delay interval, but we also need to check to see if the
:: server.up has left, if so, break out of batch file
set counter=0

:timer_loop
:: This loop is designed to pause 1 (ish) sec for "interval" seconds (see above)
:: each iteration(second) will check to see if server.up is still present
:: if not, then the server is down and exit the backup
if exist server.up (

    PING 0.0.0.0 -n 2 > nul
    set /a "counter=!counter!+1"
    if !counter! LSS %interval% GOTO timer_loop       
   
) else (GOTO quit)

GOTO backup



:: if the server.up does not exist, exit backup routine after it finishes loop
:: this way backup is not running while there is no live server
:quit
exit 0


 LIVE VIEW



Sunday, May 24, 2020

finally released (alpha)

OK, alpha release (which means it may be buggy). But my test work almost flawlessly.

head over to https:// www.blazemcpanel.com to keep up, and twitter https://twitter.com/blaze_panel




Thursday, May 14, 2020

BLAZE - MINECRAFT CONTROL PANEL

This is just a personal project of mine. Not sure if I will release, it, however until it is done, that decision will not be made at this point. I am currently using it to brush up and hone my PHP/JAVASCRIPT and CSS programming skills

At the top of the blog there is a page with some archived progress, feel free to check it out. I'll try to keep everything here.  The following is the recent design (May 2020). I felt that it did not need to be so large for a personal private Minecraft Server.  I welcome all comments and suggestions.




Monday, April 27, 2020

Castle Survival build

I am curently finishing up on one of the largest castle builds, in creative. Just to see it done. It is one of the largest I've seen in MC that actually has a tutorial. Not only is it a detailed castle inside and out, but even goes as far as gives a tutorial on the other buildings, inside and outside of the keep. Once I have this done, I will attempt to re-create this monster in survival mode. Since this is a time of the bogus COVID19 crap, it will give me at least a year of time to complete the project. If my ADD doesn't defeat me first.

The design is from the master builder BlueNerd. Check him out.

Here are some of my screenshots of the progress in creative. don't let the creative fool you, even with all the pieces at your fingertips, you will find it quite challenging with all the angles and measurements - this will complicate survival 100 fold!

There are lots of screenshots. I started the project in creative on 4/7/20 and this is how far i am at 4/27/20