Smart Prestart WIN
From OpenSimulator
(New page: '''Starting OpenSim with a little Pre-Processing''' I created this Batch File to run a couple of things for me on startup and thought it would be good to share the base of it for others ...) |
|||
Line 34: | Line 34: | ||
<blockquote><br>@echo off<br>:: FILENAME: Start_OS.BAT<br>:: AUTHOR: WhiteStar Magic @ OSGrid<br>:: DATE: REVISED SEP-15-2009<br>::<br>:: DESCRIPTION: Starts OpenSim.exe with some preprocessing<br>:: - copies opensim.log from BIN\ folder to Log Backup & renames it to OSLOG_Date@time.log<br>:: - example of output OSlog_(14052009@1019).log OR OSlog32_(14052009@1019).log <br>:: - then it CLEARS the log to EMPTY in the \BIN folder so you can see everything from startup<br>:: - WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log<br>:: - Creates backup structure under the instance to store critical files for recovery & tracking<br>:: - Copies critical files into backup structure <br>:: - BACKS UP MYSQL DB <br>::<br>:: INSTALLATION:<br>:: Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead <br>:: MODIFY the bottom lines to adjust for starting OpenSim.exe OR OpenSim.32BitLaunch.exe<br>::<br>:: DEPENDENCIES: uses Robocopy.exe (Windows Application) free from Microsoft if not in your installation<br>:: SYSTEM IMPACT: None Known <br>:: TESTED ON: Windows Vista, Windows-7RC, WINDOWS SERVER 2008-R1(64bit)<br>:: Other Windows Operating Systems should have no issue (untested) but they are consistent for this type of function<br>:: =================================================================================================================<br>:: CONFIGURING ENVIRONMENT PATHS AND SETUP TO SIMPLIFY CONFIG & ADMIN<br>:: Adjust the following to YOUR INSTALLED Folder Paths<br>::<br>:: OSbackup = Where you want your Backup File Structure to be and send files to<br>:: OSbinSrc = Where the OpenSim Software is installed and run from<br>::<br>SET OSbackup=C:\OpenSim\INSTANCEa\BACKup<br>SET OSbinSrc=C:\OpenSim\INSTANCEa\bin<br>::<br>:: MYSQL INFORMATION TO BE FILLED OUT. <br>:: IF DBUSER=XXX MySql Dump will not occur<br>set DBUSER=root<br>set DBPW=YOURPASSWORD<br>set DBNAME=opensim<br>::<br>:: --------------------------------------------------------------------------------------<br>:: DATE & TIME String Assembly<br>:: --------------------------------------------------------------------------------------<br>:: Date & Time Format on your system<br>:: Check your format in command.prompt with DATE/T<br>::<br>:: EU DATE FORMAT = 15-05-2006 DD-MM-YYYY<br>:: US DATE FORMAT = 05/17/2006 MM/DD/YYYY<br>:: TIME FORMAT 13:45:55 is truncated to 1345 and colons are ::oved <br>:: DATES are cleaned of / or - or : depending on your system install & config.<br>::<br>:: Parse Hour & Minutes Removing : or leading spaces<br>for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set HRa=%%i<br>:: fix the HR in case it has a blank in it<br>for /F "usebackq tokens=1 delims= " %%i in ('%HRa%') do set HR=%%i<br>for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set MIN=%%i<br>::<br>:: Parse the Date String ::oving unwated charachters / or - or 'space' depends on system installation<br>for /F "usebackq tokens=1,2,3,4 delims=/- " %%i in ('%DATE%') do set Tdate=%%i%%j%%k%%l<br>:: <br>set TimeStamp=%Tdate%@%HR%%MIN%<br>:: we now have a string which will appear as 12052009@0112<br>:: --------------------------------------------------------------------------------------<br>echo TimeStamp = %TimeStamp%<br>:: ==============================================<br>:: OPENSIM SYSTEM DATA BACKUP SECTION<br>:: ==============================================<br>:: <br>:: if folders do not exist, create them for this OpenSim Instance<br>:: <br>@echo OFF<br>::<br>if not exist %OSbackup%\*.* md %OSbackup%<br>if not exist %OSbackup%\DB\*.* md %OSbackup%\DB<br>if not exist %OSbackup%\DBsql\*.* md %OSbackup%\DBsql<br>if not exist %OSbackup%\EXPORTS\*.* md %OSbackup%\EXPORTS<br>if not exist %OSbackup%\INI\*.* md %OSbackup%\INI<br>if not exist %OSbackup%\LOGS\*.* md %OSbackup%\LOGS<br>if not exist %OSbackup%\OAR\*.* md %OSbackup%\OAR<br>if not exist %OSbackup%\REGIONS\*.* md %OSbackup%\REGIONS<br>if not exist %OSbackup%\TERRAINS\*.* md %OSbackup%\TERRAINS<br>if not exist %OSbackup%\TXT\*.* md %OSbackup%\TXT<br>if not exist %OSbackup%\XML2\*.* md %OSbackup%\XML2<br>:: !! Copy Critical Files !!<br>robocopy %OSbinSrc% %OSbackup%\DB *.DB /S /LOG:%OSbackup%\DBlog.txt<br>robocopy %OSbinSrc%\Exports %OSbackup%\EXPORTS *.* /S /LOG:%OSbackup%\EXPORTSlog.txt<br>robocopy %OSbinSrc% %OSbackup%\INI *.ini /S /LOG:%OSbackup%\INIlog.txt<br>robocopy %OSbinSrc%\Regions %OSbackup%\REGIONS *.* /S /LOG:%OSbackup%\REGIONSlog.txt<br>robocopy %OSbinSrc% %OSbackup%\TXT *.txt /S /LOG:%OSbackup%\TXTlog.txt<br>::<br>:: generate MySql DB Backup<br>if DBUSER NEQ XXX mysqldump --opt -u%DBUSER% -p%DBPW% %DBNAME% > %OS_Instance%\BACKup\DBsql\%DBNAME%.sql<br>::<br>if exist %OSbinSrc%\OpenSim.32BitLaunch.log copy %OSbinSrc%\OpenSim.32BitLaunch.log %OSbackup%\LOGS\OSlog32_(%TimeStamp%).log<br>if exist %OSbinSrc%\OpenSim.log copy %OSbinSrc%\OpenSim.log %OSbackup%\LOGS\OSlog_(%TimeStamp%).log<br>if exist %OSbinSrc%\XEngine.log copy %OSbinSrc%\XEngine.log %OSbackup%\LOGS\XEngine_(%TimeStamp%).log<br>::<br>:: NEXT FLUSHING LOG to EMPTY<br>if exist %OSbinSrc%\OpenSim.32BitLaunch.log >%OSbinSrc%\OpenSim.32BitLaunch.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\OpenSim.log >%OSbinSrc%\OpenSim.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\xengine.log >%OSbinSrc%\xengine.log echo "LOG_CLEARED AT %TimeStamp%"<br>::<br>@echo OFF<br>::<br>::<br>:: ==============================================<br>:: STARTING OPENSIM SERVER <br>:: ==============================================<br>:: change directory to \bin to make sure and startup system as usual<br>:: uncomment according to Operating System. OpenSim.exe = 32bit OS, OpenSim.32BitLaunch.exe = 64bit operating system <br>::<br>cd %OSbinSrc%<br>:: OpenSim.32BitLaunch.exe<br>OpenSim.exe | <blockquote><br>@echo off<br>:: FILENAME: Start_OS.BAT<br>:: AUTHOR: WhiteStar Magic @ OSGrid<br>:: DATE: REVISED SEP-15-2009<br>::<br>:: DESCRIPTION: Starts OpenSim.exe with some preprocessing<br>:: - copies opensim.log from BIN\ folder to Log Backup & renames it to OSLOG_Date@time.log<br>:: - example of output OSlog_(14052009@1019).log OR OSlog32_(14052009@1019).log <br>:: - then it CLEARS the log to EMPTY in the \BIN folder so you can see everything from startup<br>:: - WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log<br>:: - Creates backup structure under the instance to store critical files for recovery & tracking<br>:: - Copies critical files into backup structure <br>:: - BACKS UP MYSQL DB <br>::<br>:: INSTALLATION:<br>:: Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead <br>:: MODIFY the bottom lines to adjust for starting OpenSim.exe OR OpenSim.32BitLaunch.exe<br>::<br>:: DEPENDENCIES: uses Robocopy.exe (Windows Application) free from Microsoft if not in your installation<br>:: SYSTEM IMPACT: None Known <br>:: TESTED ON: Windows Vista, Windows-7RC, WINDOWS SERVER 2008-R1(64bit)<br>:: Other Windows Operating Systems should have no issue (untested) but they are consistent for this type of function<br>:: =================================================================================================================<br>:: CONFIGURING ENVIRONMENT PATHS AND SETUP TO SIMPLIFY CONFIG & ADMIN<br>:: Adjust the following to YOUR INSTALLED Folder Paths<br>::<br>:: OSbackup = Where you want your Backup File Structure to be and send files to<br>:: OSbinSrc = Where the OpenSim Software is installed and run from<br>::<br>SET OSbackup=C:\OpenSim\INSTANCEa\BACKup<br>SET OSbinSrc=C:\OpenSim\INSTANCEa\bin<br>::<br>:: MYSQL INFORMATION TO BE FILLED OUT. <br>:: IF DBUSER=XXX MySql Dump will not occur<br>set DBUSER=root<br>set DBPW=YOURPASSWORD<br>set DBNAME=opensim<br>::<br>:: --------------------------------------------------------------------------------------<br>:: DATE & TIME String Assembly<br>:: --------------------------------------------------------------------------------------<br>:: Date & Time Format on your system<br>:: Check your format in command.prompt with DATE/T<br>::<br>:: EU DATE FORMAT = 15-05-2006 DD-MM-YYYY<br>:: US DATE FORMAT = 05/17/2006 MM/DD/YYYY<br>:: TIME FORMAT 13:45:55 is truncated to 1345 and colons are ::oved <br>:: DATES are cleaned of / or - or : depending on your system install & config.<br>::<br>:: Parse Hour & Minutes Removing : or leading spaces<br>for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set HRa=%%i<br>:: fix the HR in case it has a blank in it<br>for /F "usebackq tokens=1 delims= " %%i in ('%HRa%') do set HR=%%i<br>for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set MIN=%%i<br>::<br>:: Parse the Date String ::oving unwated charachters / or - or 'space' depends on system installation<br>for /F "usebackq tokens=1,2,3,4 delims=/- " %%i in ('%DATE%') do set Tdate=%%i%%j%%k%%l<br>:: <br>set TimeStamp=%Tdate%@%HR%%MIN%<br>:: we now have a string which will appear as 12052009@0112<br>:: --------------------------------------------------------------------------------------<br>echo TimeStamp = %TimeStamp%<br>:: ==============================================<br>:: OPENSIM SYSTEM DATA BACKUP SECTION<br>:: ==============================================<br>:: <br>:: if folders do not exist, create them for this OpenSim Instance<br>:: <br>@echo OFF<br>::<br>if not exist %OSbackup%\*.* md %OSbackup%<br>if not exist %OSbackup%\DB\*.* md %OSbackup%\DB<br>if not exist %OSbackup%\DBsql\*.* md %OSbackup%\DBsql<br>if not exist %OSbackup%\EXPORTS\*.* md %OSbackup%\EXPORTS<br>if not exist %OSbackup%\INI\*.* md %OSbackup%\INI<br>if not exist %OSbackup%\LOGS\*.* md %OSbackup%\LOGS<br>if not exist %OSbackup%\OAR\*.* md %OSbackup%\OAR<br>if not exist %OSbackup%\REGIONS\*.* md %OSbackup%\REGIONS<br>if not exist %OSbackup%\TERRAINS\*.* md %OSbackup%\TERRAINS<br>if not exist %OSbackup%\TXT\*.* md %OSbackup%\TXT<br>if not exist %OSbackup%\XML2\*.* md %OSbackup%\XML2<br>:: !! Copy Critical Files !!<br>robocopy %OSbinSrc% %OSbackup%\DB *.DB /S /LOG:%OSbackup%\DBlog.txt<br>robocopy %OSbinSrc%\Exports %OSbackup%\EXPORTS *.* /S /LOG:%OSbackup%\EXPORTSlog.txt<br>robocopy %OSbinSrc% %OSbackup%\INI *.ini /S /LOG:%OSbackup%\INIlog.txt<br>robocopy %OSbinSrc%\Regions %OSbackup%\REGIONS *.* /S /LOG:%OSbackup%\REGIONSlog.txt<br>robocopy %OSbinSrc% %OSbackup%\TXT *.txt /S /LOG:%OSbackup%\TXTlog.txt<br>::<br>:: generate MySql DB Backup<br>if DBUSER NEQ XXX mysqldump --opt -u%DBUSER% -p%DBPW% %DBNAME% > %OS_Instance%\BACKup\DBsql\%DBNAME%.sql<br>::<br>if exist %OSbinSrc%\OpenSim.32BitLaunch.log copy %OSbinSrc%\OpenSim.32BitLaunch.log %OSbackup%\LOGS\OSlog32_(%TimeStamp%).log<br>if exist %OSbinSrc%\OpenSim.log copy %OSbinSrc%\OpenSim.log %OSbackup%\LOGS\OSlog_(%TimeStamp%).log<br>if exist %OSbinSrc%\XEngine.log copy %OSbinSrc%\XEngine.log %OSbackup%\LOGS\XEngine_(%TimeStamp%).log<br>::<br>:: NEXT FLUSHING LOG to EMPTY<br>if exist %OSbinSrc%\OpenSim.32BitLaunch.log >%OSbinSrc%\OpenSim.32BitLaunch.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\OpenSim.log >%OSbinSrc%\OpenSim.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\xengine.log >%OSbinSrc%\xengine.log echo "LOG_CLEARED AT %TimeStamp%"<br>::<br>@echo OFF<br>::<br>::<br>:: ==============================================<br>:: STARTING OPENSIM SERVER <br>:: ==============================================<br>:: change directory to \bin to make sure and startup system as usual<br>:: uncomment according to Operating System. OpenSim.exe = 32bit OS, OpenSim.32BitLaunch.exe = 64bit operating system <br>::<br>cd %OSbinSrc%<br>:: OpenSim.32BitLaunch.exe<br>OpenSim.exe | ||
</blockquote> | </blockquote> | ||
+ | |||
+ | |||
+ | ---- | ||
+ | '''BACK-LINKS''' | ||
+ | |||
+ | == Windows == | ||
+ | [[Smart Prestart WIN]] [[Backing Up WIN]] [[Automated Upgrade WIN]] | ||
+ | |||
+ | == Linux == | ||
+ | [[Smart Prestart LINUX]] [[Backing Up LINUX]] [[Automated Upgrade LINUX]] |
Revision as of 19:02, 15 September 2009
Starting OpenSim with a little Pre-Processing
I created this Batch File to run a couple of things for me on startup and thought it would be good to share the base of it for others to be able to further better manage their systems. I like to review my OpenSim.Log when I do a Startup and as you know, that thing becomes a Monster very fast ! BTW: It's also not good to open the "Live Log" when the system is running because it can cause the console to lockup (hate file locking @ times).
- What this does is described in the batch file, in a nutshell:
Presets a TimeStamp for Date@HourMinute
- Copies \bin\opensim.log or \bin\opensim.32bitLaunch.log to the backup folder structure as defined.
- The DEFAULT is C:\OpenSim\InstanceA\BACKups\LOGS
- Next, it renames the copied opensim.log to OSLOG_(14052009@1100).log so now it is Date@HourMinute stamped in the filename.
- Next, it clears the \bin\opensim.log and inserts "LOG_CLEARED AT 14052009@1100" as the first line in the file.
- WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log
- Creates backup structure under the instance to store critical files for recovery & tracking
- Copies critical files into backup structure (*.db, *.ini, exports, regions files ini or xml)
- OPTIONALLY BACKS UP MYSQL DB
- Changes directory to the \BIN folder and starts OpenSim.exe
INSTALLATION:
- Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead instead of opensim.exe
- !! Remember to set the 5 Important Variables for your paths at the top of the batch file as shown below:
- OPTIONALLY Now Also dumps MySql DataBase SEE Header in batchfile
SET OSbackup=C:\OpenSim\InstanceA\BACKups
SET OSbinSrc=C:\OpenSim\InstanceA\bin
set DBUSER=root
set DBPW=YOURPASSWORD
set DBNAME=opensim
That's it... Nice & Easy, always a clean log when you startup and a copy of the previous log stored for you to review
THE BATCHFILE Start_OS.BAT
@echo off
:: FILENAME: Start_OS.BAT
:: AUTHOR: WhiteStar Magic @ OSGrid
:: DATE: REVISED SEP-15-2009
::
:: DESCRIPTION: Starts OpenSim.exe with some preprocessing
:: - copies opensim.log from BIN\ folder to Log Backup & renames it to OSLOG_Date@time.log
:: - example of output OSlog_(14052009@1019).log OR OSlog32_(14052009@1019).log
:: - then it CLEARS the log to EMPTY in the \BIN folder so you can see everything from startup
:: - WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log
:: - Creates backup structure under the instance to store critical files for recovery & tracking
:: - Copies critical files into backup structure
:: - BACKS UP MYSQL DB
::
:: INSTALLATION:
:: Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead
:: MODIFY the bottom lines to adjust for starting OpenSim.exe OR OpenSim.32BitLaunch.exe
::
:: DEPENDENCIES: uses Robocopy.exe (Windows Application) free from Microsoft if not in your installation
:: SYSTEM IMPACT: None Known
:: TESTED ON: Windows Vista, Windows-7RC, WINDOWS SERVER 2008-R1(64bit)
:: Other Windows Operating Systems should have no issue (untested) but they are consistent for this type of function
:: =================================================================================================================
:: CONFIGURING ENVIRONMENT PATHS AND SETUP TO SIMPLIFY CONFIG & ADMIN
:: Adjust the following to YOUR INSTALLED Folder Paths
::
:: OSbackup = Where you want your Backup File Structure to be and send files to
:: OSbinSrc = Where the OpenSim Software is installed and run from
::
SET OSbackup=C:\OpenSim\INSTANCEa\BACKup
SET OSbinSrc=C:\OpenSim\INSTANCEa\bin
::
:: MYSQL INFORMATION TO BE FILLED OUT.
:: IF DBUSER=XXX MySql Dump will not occur
set DBUSER=root
set DBPW=YOURPASSWORD
set DBNAME=opensim
::
:: --------------------------------------------------------------------------------------
:: DATE & TIME String Assembly
:: --------------------------------------------------------------------------------------
:: Date & Time Format on your system
:: Check your format in command.prompt with DATE/T
::
:: EU DATE FORMAT = 15-05-2006 DD-MM-YYYY
:: US DATE FORMAT = 05/17/2006 MM/DD/YYYY
:: TIME FORMAT 13:45:55 is truncated to 1345 and colons are ::oved
:: DATES are cleaned of / or - or : depending on your system install & config.
::
:: Parse Hour & Minutes Removing : or leading spaces
for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set HRa=%%i
:: fix the HR in case it has a blank in it
for /F "usebackq tokens=1 delims= " %%i in ('%HRa%') do set HR=%%i
for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set MIN=%%i
::
:: Parse the Date String ::oving unwated charachters / or - or 'space' depends on system installation
for /F "usebackq tokens=1,2,3,4 delims=/- " %%i in ('%DATE%') do set Tdate=%%i%%j%%k%%l
::
set TimeStamp=%Tdate%@%HR%%MIN%
:: we now have a string which will appear as 12052009@0112
:: --------------------------------------------------------------------------------------
echo TimeStamp = %TimeStamp%
:: ==============================================
:: OPENSIM SYSTEM DATA BACKUP SECTION
:: ==============================================
::
:: if folders do not exist, create them for this OpenSim Instance
::
@echo OFF
::
if not exist %OSbackup%\*.* md %OSbackup%
if not exist %OSbackup%\DB\*.* md %OSbackup%\DB
if not exist %OSbackup%\DBsql\*.* md %OSbackup%\DBsql
if not exist %OSbackup%\EXPORTS\*.* md %OSbackup%\EXPORTS
if not exist %OSbackup%\INI\*.* md %OSbackup%\INI
if not exist %OSbackup%\LOGS\*.* md %OSbackup%\LOGS
if not exist %OSbackup%\OAR\*.* md %OSbackup%\OAR
if not exist %OSbackup%\REGIONS\*.* md %OSbackup%\REGIONS
if not exist %OSbackup%\TERRAINS\*.* md %OSbackup%\TERRAINS
if not exist %OSbackup%\TXT\*.* md %OSbackup%\TXT
if not exist %OSbackup%\XML2\*.* md %OSbackup%\XML2
:: !! Copy Critical Files !!
robocopy %OSbinSrc% %OSbackup%\DB *.DB /S /LOG:%OSbackup%\DBlog.txt
robocopy %OSbinSrc%\Exports %OSbackup%\EXPORTS *.* /S /LOG:%OSbackup%\EXPORTSlog.txt
robocopy %OSbinSrc% %OSbackup%\INI *.ini /S /LOG:%OSbackup%\INIlog.txt
robocopy %OSbinSrc%\Regions %OSbackup%\REGIONS *.* /S /LOG:%OSbackup%\REGIONSlog.txt
robocopy %OSbinSrc% %OSbackup%\TXT *.txt /S /LOG:%OSbackup%\TXTlog.txt
::
:: generate MySql DB Backup
if DBUSER NEQ XXX mysqldump --opt -u%DBUSER% -p%DBPW% %DBNAME% > %OS_Instance%\BACKup\DBsql\%DBNAME%.sql
::
if exist %OSbinSrc%\OpenSim.32BitLaunch.log copy %OSbinSrc%\OpenSim.32BitLaunch.log %OSbackup%\LOGS\OSlog32_(%TimeStamp%).log
if exist %OSbinSrc%\OpenSim.log copy %OSbinSrc%\OpenSim.log %OSbackup%\LOGS\OSlog_(%TimeStamp%).log
if exist %OSbinSrc%\XEngine.log copy %OSbinSrc%\XEngine.log %OSbackup%\LOGS\XEngine_(%TimeStamp%).log
::
:: NEXT FLUSHING LOG to EMPTY
if exist %OSbinSrc%\OpenSim.32BitLaunch.log >%OSbinSrc%\OpenSim.32BitLaunch.log echo "LOG_CLEARED AT %TimeStamp%"
if exist %OSbinSrc%\OpenSim.log >%OSbinSrc%\OpenSim.log echo "LOG_CLEARED AT %TimeStamp%"
if exist %OSbinSrc%\xengine.log >%OSbinSrc%\xengine.log echo "LOG_CLEARED AT %TimeStamp%"
::
@echo OFF
::
::
:: ==============================================
:: STARTING OPENSIM SERVER
:: ==============================================
:: change directory to \bin to make sure and startup system as usual
:: uncomment according to Operating System. OpenSim.exe = 32bit OS, OpenSim.32BitLaunch.exe = 64bit operating system
::
cd %OSbinSrc%
:: OpenSim.32BitLaunch.exe
OpenSim.exe
BACK-LINKS
Windows
Smart Prestart WIN Backing Up WIN Automated Upgrade WIN
Linux
Smart Prestart LINUX Backing Up LINUX Automated Upgrade LINUX