Smart Prestart WIN

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(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 ...)
 
m (Robot: Replacing 'OpenSim' to 'OpenSimulator', which is the precise name)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Starting OpenSim with a little Pre-Processing'''  
+
{{Quicklinks}}
 +
 
 +
'''Starting OpenSimulator 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).  
 
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).  
  
<br>
+
<br />
  
*'''What this does is described in the batch file, in a nutshell:<br>'''
+
* '''What this does is described in the batch file, in a nutshell:<br />'''
  
 
Presets a TimeStamp for Date@HourMinute  
 
Presets a TimeStamp for Date@HourMinute  
  
*Copies \bin\opensim.log or&nbsp;\bin\opensim.32bitLaunch.log&nbsp;to the backup folder structure as&nbsp;defined.  
+
* Copies \bin\opensim.log or&nbsp;\bin\opensim.32bitLaunch.log&nbsp;to the backup folder structure as&nbsp;defined.  
*''The DEFAULT is&nbsp;C:\OpenSim\InstanceA\BACKups\LOGS''  
+
* ''The DEFAULT is&nbsp;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 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.  
+
* 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  
+
* 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 &amp; tracking  
+
* Creates backup structure under the instance to store critical files for recovery &amp; tracking  
*Copies critical files into backup structure&nbsp;(*.db, *.ini, exports, regions files ini or xml)  
+
* Copies critical files into backup structure&nbsp;(*.db, *.ini, exports, regions files ini or xml)  
*OPTIONALLY BACKS UP MYSQL DB  
+
* OPTIONALLY BACKS UP MYSQL DB  
*Changes directory to the \BIN folder and starts OpenSim.exe
+
* Changes directory to the \BIN folder and starts OpenSim.exe
 +
 
 +
<br />
  
<br>
+
'''INSTALLATION: <br />'''
  
'''INSTALLATION: <br>'''
+
* 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
  
*Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead instead of opensim.exe
+
SET OSbackup=C:\OpenSim\InstanceA\BACKups<br />SET OSbinSrc=C:\OpenSim\InstanceA\bin<br />set DBUSER=root<br />set DBPW=YOURPASSWORD<br />set DBNAME=opensim
*'''!!''' 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<br>SET OSbinSrc=C:\OpenSim\InstanceA\bin<br>set DBUSER=root<br>set DBPW=YOURPASSWORD<br>set DBNAME=opensim
+
<br />That's it... Nice &amp; Easy, always a clean log when you startup and a copy of the previous log stored for you to review
  
<br>That's it... Nice &amp; 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'''
 +
<blockquote><source lang="text">@echo off
 +
:: FILENAME: Start_OS.BAT
 +
:: AUTHOR: WhiteStar Magic @ OSGrid
 +
:: DATE: REVISED Nov-24.2010
 +
::
 +
:: 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_(24-11-2010@23-27).log OR OSlog32_(24-11-2010@23-27).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 OpenSimulator Software is installed and run from
 +
::
 +
SET OSbackup=C:\OPENSIM\instanceA\BACKups
 +
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=PASSWORD
 +
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 13-45 and colons are removed
 +
:: DATES are cleaned of / or - or : depending on your system install & config.
 +
::
 +
:: Parse Hour & Minutes Removing incorrect characters or leading spaces
 +
:: i=HR, j=min, k=sec,l=msec
 +
for /F "usebackq tokens=1,2,3,4 delims=/-:. " %%i in ('%TIME%') do set Ttime=%%i-%%j
 +
::
 +
:: Parse the Date String removing unwated characters / 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
 +
::
 +
set TimeStamp=%Tdate%@%Ttime%
 +
:: we now have a string which will appear as 24-11-2010@23-27
 +
:: --------------------------------------------------------------------------------------
 +
echo TimeStamp = %TimeStamp%
 +
:: ==============================================
 +
:: OPENSIM SYSTEM DATA BACKUP SECTION
 +
:: ==============================================
 +
::
 +
:: if folders do not exist, create them for this OpenSimulator Instance
 +
::
 +
::
 +
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% > %OSbackup%\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%"
 +
::
 +
::
 +
::
 +
:: ==============================================
 +
:: 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</source></blockquote>
 +
----
  
THE BATCHFILE '''Start_OS.BAT'''
+
Return to [[Automating Tasks]]
<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 &amp; 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 &amp; 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 &amp; 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 &amp; TIME String Assembly<br>:: --------------------------------------------------------------------------------------<br>:: Date &amp; 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 &amp; config.<br>::<br>:: Parse Hour &amp; 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% &gt; %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 &gt;%OSbinSrc%\OpenSim.32BitLaunch.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\OpenSim.log &gt;%OSbinSrc%\OpenSim.log echo "LOG_CLEARED AT %TimeStamp%"<br>if exist %OSbinSrc%\xengine.log &gt;%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>
+

Latest revision as of 23:59, 3 March 2012

Starting OpenSimulator 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 Nov-24.2010
::
:: 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_(24-11-2010@23-27).log OR OSlog32_(24-11-2010@23-27).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 OpenSimulator Software is installed and run from
::
SET OSbackup=C:\OPENSIM\instanceA\BACKups
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=PASSWORD
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 13-45 and colons are removed 
:: DATES are cleaned of / or - or : depending on your system install & config.
::
:: Parse Hour & Minutes Removing incorrect characters or leading spaces
:: i=HR, j=min, k=sec,l=msec
 for /F "usebackq tokens=1,2,3,4 delims=/-:. " %%i in ('%TIME%') do set Ttime=%%i-%%j
::
:: Parse the Date String removing unwated characters / 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
:: 
set TimeStamp=%Tdate%@%Ttime%
:: we now have a string which will appear as 24-11-2010@23-27
:: --------------------------------------------------------------------------------------
echo TimeStamp = %TimeStamp%
:: ==============================================
:: OPENSIM SYSTEM DATA BACKUP SECTION
:: ==============================================
:: 
:: if folders do not exist, create them for this OpenSimulator Instance
:: 
::
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% > %OSbackup%\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%"
::
::
::
:: ==============================================
:: 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

Return to Automating Tasks

Personal tools
General
About This Wiki