Jump to content

[Share] GS.bat With Auto-Backup


Recommended Posts

I was browsing L2J Forum & I have found a very useful tool ( well, at least for me :P )

Anyway i hope you like it !!

 

It is a "special" Gameserver.bat With Auto-Backup.You need to edit some things in the code in order to make auto-back :P

 

 

::::::::::
:: Config

:: Title of the server window.
@title GameServer

:: You can get more information about the color command by opening "Start - Run.." and typing:
:: cmd /k color /?
:: for example "@color 0a" will give the server console a matrix-like look.
:: default: color 07
@color 07

:: window size.
:: cols=number of symbols on one line, default is 80
:: lines=number of lines in one window, default is 300
:: remove "::" to activate
::

:: mode con: cols=80 lines=300
:: The command that will start the server.
:: You can start the server in high process priority if you change the default execution line to:
:: @set exec=start /wait /realtime java -Xmx512m -cp bsf.jar;bsh-2.0b4.jar;commons-logging-1.1.jar;mmocore.jar;javolution.jar;c3p0-0.9.1.jar;mysql-connector-java-5.0.5-bin.jar;l2jserver.jar;jython.jar net.sf.l2j.gameserver.GameServer
:: But this will also create one extra CMD window.

@set exec=java -Xmx512m -cp bsf.jar;bsh-2.0b4.jar;commons-logging-1.1.jar;mmocore.jar;javolution.jar;c3p0-0.9.1.jar;mysql-connector-java-5.0.5-bin.jar;l2jserver.jar;jython.jar net.sf.l2j.gameserver.GameServer

::
:: MySQL
::

@set mysqlPath="C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql"
@set mysqlBinPath="C:\Program Files\MySQL\MySQL Server 5.0\bin"
@set mysqldumpPath="C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump"
@set lsuser=root
@set lspass=
@set lsdb=l2jdb
@set lshost=localhost
@set gsuser=root
@set gspass=
@set gsdb=l2jdb
@set gshost=localhost

::
:: Log
::

:: The log file that will show when the server was started, restarted and shutdown.
@set StartEndLog_Enable=true
@set StartEndLog_Path="log/start-end.log"

:: Logging of database backup.
@set DatabaseBackupLog_Enable=true
@set DatabaseBackupLog_Path="log/start-end.log"

:: item.log
:: This file is created by the server if the item logging is enabled and it
:: gets very large very quickly.
:: Enable this option to move the item.log file to the backup folder every
:: time the database bacup is running.
@set MoveItemLog=true

::
:: Database Backup
::

@set DatabaseBackupOnStart_Enable=false
@set DatabaseBackupOnShutdown_Enable=true
@set DatabaseBackupOnRestart_Enable=true
@set DatabaseBackupOnAbnormal_Enable=true
@set DatabaseBackupPath=c:\backup

:: Config
::::::::::

@echo off
:start

:: --- Start of the backup script --- ::
if not "%DatabaseBackupOnStart_Enable%"=="true" goto EndBackup1
if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Starting>> %DatabaseBackupLog_Path%
for /F "tokens=2" %%I in ("%date%") do set CurrentDate=%%I
set BackupPath=%CurrentDate%-%random%
echo Backup will be saved in: %DatabaseBackupPath%\%BackupPath%
if not exist %DatabaseBackupPath% md %DatabaseBackupPath%&echo "%DatabaseBackupPath%" doesn't exist, creating path...
if not exist %DatabaseBackupPath% echo Couldn't create "%DatabaseBackupPath%", Backup canceled!&goto EndBackup1

md "%DatabaseBackupPath%\%BackupPath%"

if not "%MoveItemLog%"=="true" goto EndMoveItemLog1
if not exist log\item.log echo "item.log" doesn't exist.&goto EndMoveItemLog1
echo Moving item.log to "%DatabaseBackupPath%\%BackupPath%"
move log\item.log "%DatabaseBackupPath%\%BackupPath%\item.log"
echo.
:EndMoveItemLog1

echo Loginserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% > "%DatabaseBackupPath%\%BackupPath%\loginserver.sql"
echo.
echo Gameserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% > "%DatabaseBackupPath%\%BackupPath%\gameserver.sql"
echo.
echo Done.
echo.
goto EndBackup1

if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Finished>> %DatabaseBackupLog_Path%
:EndBackup1
:: --- End of the backup script --- ::



if "%StartEndLog_Enable%"=="true" echo %date% ^| %time% ^| Gameserver: Starting>> %StartEndLog_Path%
echo Starting L2J Game Server.
echo.

:: --- Server starting here --- ::
%exec%
:: --- Server Stoping here --- ::

if ERRORLEVEL 2 goto restart
if ERRORLEVEL 1 goto error

:: --- Start of the backup script --- ::
if not "%DatabaseBackupOnShutdown_Enable%"=="true" goto EndBackup2
if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Starting>> %DatabaseBackupLog_Path%
for /F "tokens=2" %%I in ("%date%") do set CurrentDate=%%I
set BackupPath=%CurrentDate%-%random%
echo Backup will be saved in: "%DatabaseBackupPath%\%BackupPath%"
if not exist %DatabaseBackupPath% md %DatabaseBackupPath%&echo "%DatabaseBackupPath%" doesn't exist, creating path...
if not exist %DatabaseBackupPath% echo Couldn't create "%DatabaseBackupPath%", Backup canceled!&goto EndBackup2

md "%DatabaseBackupPath%\%BackupPath%"

if not "%MoveItemLog%"=="true" goto EndMoveItemLog2
if not exist log\item.log echo "item.log" doesn't exist.&goto EndMoveItemLog2
echo Moving item.log to "%DatabaseBackupPath%\%BackupPath%"
move log\item.log "%DatabaseBackupPath%\%BackupPath%\item.log"
echo.
:EndMoveItemLog2

echo Loginserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% > "%DatabaseBackupPath%\%BackupPath%\loginserver.sql"
echo.
echo Gameserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% > "%DatabaseBackupPath%\%BackupPath%\gameserver.sql"
echo.
echo Done.
echo.

if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Finished>> %DatabaseBackupLog_Path%
:EndBackup2
:: --- End of the backup script --- ::


if "%StartEndLog_Enable%"=="true" echo %date% ^| %time% ^| Gameserver: Server Shutdown>> %StartEndLog_Path%
goto end
:restart

:: --- Start of the backup script --- ::
if not "%DatabaseBackupOnRestart_Enable%"=="true" goto EndBackup3
if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Starting>> %DatabaseBackupLog_Path%
for /F "tokens=2" %%I in ("%date%") do set CurrentDate=%%I
set BackupPath=%CurrentDate%-%random%
echo Backup will be saved in: "%DatabaseBackupPath%\%BackupPath%"
if not exist %DatabaseBackupPath% md %DatabaseBackupPath%&echo "%DatabaseBackupPath%" doesn't exist, creating path...
if not exist %DatabaseBackupPath% echo Couldn't create "%DatabaseBackupPath%", Backup canceled!&goto EndBackup3

md "%DatabaseBackupPath%\%BackupPath%"

if not "%MoveItemLog%"=="true" goto EndMoveItemLog3
if not exist log\item.log echo "item.log" doesn't exist.&goto EndMoveItemLog3
echo Moving item.log to "%DatabaseBackupPath%\%BackupPath%"
move log\item.log "%DatabaseBackupPath%\%BackupPath%\item.log"
echo.
:EndMoveItemLog3

echo Loginserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% > "%DatabaseBackupPath%\%BackupPath%\loginserver.sql"
echo.
echo Gameserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% > "%DatabaseBackupPath%\%BackupPath%\gameserver.sql"
echo.
echo Done.
echo.


if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Finished>> %DatabaseBackupLog_Path%
:EndBackup3
:: --- End of the backup script --- ::


if "%StartEndLog_Enable%"=="true" echo %date% ^| %time% ^| Gameserver: Admin Restart>> %StartEndLog_Path%
echo.
echo Admin Restart ...
echo.
goto start
:error
:: --- Start of the backup script --- ::
if not "%DatabaseBackupOnAbnormal_Enable%"=="true" goto EndBackup4
if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Starting>> %DatabaseBackupLog_Path%
for /F "tokens=2" %%I in ("%date%") do set CurrentDate=%%I
set BackupPath=%CurrentDate%-%random%
echo Backup will be saved in: "%DatabaseBackupPath%\%BackupPath%"
if not exist %DatabaseBackupPath% md %DatabaseBackupPath%&echo "%DatabaseBackupPath%" doesn't exist, creating path...
if not exist %DatabaseBackupPath% echo Couldn't create "%DatabaseBackupPath%", Backup canceled!&goto EndBackup4

md "%DatabaseBackupPath%\%BackupPath%"

if not "%MoveItemLog%"=="true" goto EndMoveItemLog4
if not exist log\item.log echo "item.log" doesn't exist.&goto EndMoveItemLog4
echo Moving item.log to "%DatabaseBackupPath%\%BackupPath%"
move log\item.log "%DatabaseBackupPath%\%BackupPath%\item.log"
echo.
:EndMoveItemLog4

echo Loginserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %lshost% -u %lsuser% --password=%lspass% %lsdb% > "%DatabaseBackupPath%\%BackupPath%\loginserver.sql"
echo.
echo Gameserver backup.
echo -------------------
%mysqldumpPath% --add-drop-table -h %gshost% -u %gsuser% --password=%gspass% %gsdb% > "%DatabaseBackupPath%\%BackupPath%\gameserver.sql"
echo.
echo Done.
echo.


if "%DatabaseBackupLog_Enable%"=="true" echo %date% ^| %time% ^| Backup: Finished>> %DatabaseBackupLog_Path%
:EndBackup4
:: --- End of the backup script --- ::
if "%StartEndLog_Enable%"=="true" echo %date% ^| %time% ^| Gameserver: Server terminated abnormaly>> %StartEndLog_Path%
echo.
echo Server terminated abnormaly
echo.
:end
echo.
echo server terminated
echo.
pause

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 11 months later...
Guest
This topic is now closed to further replies.


  • Posts

    • thats 26_21... i have it and 26_19... only 26_20 missing is the town arcan part
    • his link still working here , or are they different ?
    • Hello everyone,   We're shifting our focus away from implementing as much as possible from the Essence gameplay. Instead, the server will now be Interlude, but using the Essence client.   This should be good news for everyone.   The Beta phase will most likely take place in November, with the grand opening to follow shortly after.   Cheers!
    • We remind you that the opening will take place today, on September 28 at: 19:00 (UTC+3) - server time Check current server time(UTC +3) On 17:00 (UTC +3) We allow you login to create character! Dear friends, this topic important! So please take time to read it. First we want to thank all players who took part in the Open Beta testing, was good activity and nice Olympiad Event yesterday, we all get a lot of fun  Thanks to all who conducted tests with us and prepared this game world! You are amazing!  On 17:00 (UTC +3) We allow you to login for create character! To restrict your name and transfer ToDs/Season Pack to your character. Make it before start! On start, we can have problems with WEB! Everything you need to start on the server: It is IMPORTANT to prepare everything for starting the game RIGHT NOW, do not postpone for later, during the opening there may be problems with the web part of the project, and you simply can not register. - Registration and files Download archive unzip it, run launcher, choose SEASON x25 server and press FULL CHECK What you need to know at the start: Registration for 7 seals from Monday, September 30, full cycle 1 week. First Mammons on Friday October 4 All Epic Raid Bosses dead on start. First epic QA will appear on Monday, next day Core + Zaken + QA and so on by schedule All other RBs alive on server start (including Sub and Nobl RB) - Full RoadMap   About possible attacks on server start. We have prepared as good as we can. We will control the start of the server together with you. Want to ask you, in the case of a problem, don't panic, panic is the worst possible thing that could be, even worse than any attack. We have enough specialists to solve any problems, all that will need from you is patience and trust. Wish you all a smooth start and months of enjoyable play in new Season Interlude x25! Have a fun!
  • Topics

×
×
  • Create New...