Jump to content

Recommended Posts

Posted

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

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


×
×
  • Create New...