Backing Up WIN

= BACKING UP IN WINDOWS =

This Posting now includes the more complete Automation System for OpenSim .

SYSTEMS TESTED ON Windows Vista, Windows-7 RC1, Server 2008 r1 (64bit) MySql 5.1 This works will all system up to OpenSim 9700 to Current GIT# c5455d4 - r10713

Prior to ANY UPGRADE / UPDATE you need to backup your system !

So here I present a BACKUP SCRIPT &amp; RESTORE SCRIPT for the Console, along Batch File at the end to complete the process. This should be used in conjunstion with the Smart Prestart WIN

This is Comprehensive, as it is better to have all types of backups in case OAR or others fail! (It Happens!)

You can copy these command scripts provided into your \BIN Folder.

Highly Recomended: This System is designed to operated with the following SubStructures to isolate your Backups for Easy Retrieval and archiving. SINGLE INSTANCE OF OPENSIM  "c:\OpenSim &lt; Base installation c:\OpenSim\bin &lt; the bin Folder c:\OpenSim\BACKups &lt; The Backup SubFolder Structure 'base/root' (could be anywhere) !! Best to keep it OUT of \bin and it's subfolders c:\OpenSim\BACKups\DB &lt; for SqlLite Databases c:\OpenSim\BACKups\DBsql &lt; for MySql Databases c:\OpenSim\BACKups\EXPORTS &lt; ExportDirectories transfered here c:\OpenSim\BACKups\INI &lt; ALL Active INI Files from BIN and SubDirectories c:\OpenSim\BACKups\LOGS &lt; Log Files Archived Here for Review c:\OpenSim\BACKups\OAR &lt; for OAR Files c:\OpenSim\BACKups\REGIONS &lt; Region.XML or INI files copied here c:\OpenSim\BACKups\TERRAINS &lt; for r32 Terrain Files c:\OpenSim\BACKups\TXT &lt; TXT files used for console scripts copied here c:\OpenSim\BACKups\XML2 &lt; for XML2 Files" Note that EXPORTS are saved in \bin\exports by default, as defined in the OpenSim.ini

IF YOU HAVE MULTIPLE INSTANCES, CHANGE PATHING ACCORDINGLY  "C:\OpenSim\INSTANCEa &lt; Base installation C:\OpenSim\INSTANCEa\bin &lt; the bin Folder C:\OpenSim\INSTANCEa\BACKups &lt; The Backup SubFolder Structure 'base/root' (could be anywhere) !! Best to keep it OUT of \bin and it's subfolders C:\OpenSim\INSTANCEa\BACKups\DB &lt; for SqlLite Databases C:\OpenSim\INSTANCEa\BACKups\DBsql &lt; for MySql Databases C:\OpenSim\INSTANCEa\BACKups\EXPORTS &lt; ExportDirectories transfered here C:\OpenSim\INSTANCEa\BACKups\INI &lt; ALL Active INI Files from BIN and SubDirectories C:\OpenSim\INSTANCEa\BACKups\LOGS &lt; Log Files Archived Here for Review C:\OpenSim\INSTANCEa\BACKups\OAR &lt; for OAR Files C:\OpenSim\INSTANCEa\BACKups\REGIONS &lt; Region.XML or INI files copied here C:\OpenSim\INSTANCEa\BACKups\TERRAINS &lt; for r32 Terrain Files C:\OpenSim\INSTANCEa\BACKups\TXT &lt; TXT files used for console scripts copied here C:\OpenSim\INSTANCEa\BACKups\XML2 &lt; for XML2 Files" '''SPECIAL NOTE! '''The PRESTART Batch File in Smart_Prestart_WIN will autobuild these structures &amp; Perform several important functions

To Run this script, type the following in your console IF BACKUP.TXT is saved in your \bin folder. command-script backup.txt

CONSOLE SCRIPT "BACKUP.TXT" "; Description: of BACKUP.TXT ; Creates a Full System Backup of all critical data ; Uses Command Console Functions not available otherwise ; ; Creates OAR, XML2, R32 (Region Terrain Files), and places them into the predefined folder structure. ; Modify the folder structure according to your installation ; ; NOTE The Export goes to the default as defined in opensim.ini it is NOT SUGGESTED that this be changed ; ; EXAMPLE is provided for a multi-region install. If you only have one region, or more adjust accordingly ; RENAME Region1, Region2 etc ... according to your region names ; ; OAR FILES ! They do take a while depending on the volume of data on the region. The script will proceed ; and the commands will be queued and processed. IF you watch the destination folder, you will see teh OAR files grow ; as they are being written out to the hard drive. Be Patient if you have a large installation. ; This will imapct system response to those In-World on the region being processed! ; change region root backup export save-all ; change region Region1 terrain save c:\OpenSim\BACKups\TERRAINS\Region1.r32 save xml2 c:\OpenSim\BACKups\XML2\Region1.xml save oar c:\OpenSim\BACKups\OAR\Region1.tar.gz ; change region Region2 terrain save c:\OpenSim\BACKups\TERRAINS\Region2.r32 save xml2 c:\OpenSim\BACKups\XML2\Region2.xml save oar c:\OpenSim\BACKups\OAR\Region2.tar.gz ; ; REPEAT AS NECESSARY, edit 'Region#' and change it to YOUR REGION NAME" RESTORATION: To Run this script, type the following in your console IF RESTORE.TXT is saved in your \bin folder. command-script restore.txt

CONSOLE SCRIPT "RESTORE.TXT"


 * FULL RESTORE PROCESS for OPENSIM CONSOLE ; Description
 * ; Uses Command Console Functions not available otherwise ; ; RESTORES OAR, R32 (Region Terrain Files), and places them into the Original Regions ; from the Backup\Folder structures as previously defined ; CAN be used to restore XML2 but commented out, there as last resort, IF needed ; ; EXAMPLE is provided for a multi-Region install. If you only have one Region, or more adjust accordingly ; RENAME Region1, Region2 etc ... according to your Region names ; ; OAR FILES ! They do take a while depending on the volume of data on the Region. The script will proceed ; and the commands will be queued and processed. ; change region Region1 terrain load c:\OpenSim\BACKups\TERRAINS\Region1.r32 load oar c:\OpenSim\BACKups\OAR\Region1.tar.gz ; load xml2 c:\OpenSim\BACKups\BACKups\XML2\Region1.xml ; change region Region2 terrain load c:\OpenSim\BACKups\TERRAINS\Region2.r32 load oar c:\OpenSim\BACKups\OAR\Region2.tar.gz ; load xml2 c:\OpenSim\BACKups\XML2\Region2.xml ; ; you will see messages on the console as it completes queued tasks

BATCH File Name: FullBackup.bat Command to execute: Run in command prompt OR Task Scheduler Description: Copies opensim SQL database out &amp; Everything else Important CAVEATS: none known LOCATION: Place in folder with other Batch CMD files @ C:\OpenSim\InstanceA Where InstanceA is the directory ABOVE C:\OpenSim\InstanceA\bin DEPENDENCIES: Use the Posted Console command-script following this, They work together! "@echo off :: FILENAME: FullBackup.bat :: AUTHOR: WhiteStar Magic @ OSGrid :: DATE: REVISED SEP-15-2009 :: :: Operational Under Windows Vista SP1 TO Win Server 2008 R1 (64bit) :: Suitable under other Windows Platforms, but not tested :: :: Added MySql Functions :: Added Further Commenting to better explain what is being done :: Added Additional Folder Backups (Exports complete) :: Added INI &amp; TXT File Backups as well, Accounting for Murphys Laws, (you never know) :: Revised MAY.14.2009 :: Correction added for TimeStamp to remove leading space from time IF time is &lt; 12:00 (Operating System Quirk) :: :: Robocopy.exe can be downloaded from Microsoft Corp/MSDN Website. Search for it and get the latest version. :: XP &amp; Vista Users ! It works fine as long as you have the latest. :: ROBOCOPY COMMANDS AS USED :: SourceFolder TargetFolder FileName /S = DoSubFolders (non-empty) /LOG = Generate LOG of execution :: :: Place this batch file into Microsoft Scheduler, set to daily :: Other scheduler systems can also be used if desired :: ===================================================================================== :: :: CONFIGURING ENVIRONMENT PATHS AND SETUP TO SIMPLIFY CONFIG &amp; 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\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=YOURPASSWORD set DBNAME=opensim :: :: -- :: DATE &amp; TIME String Assembly :: -- :: Date &amp; 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 removed :: DATES are cleaned of / or - or : depending on your system install &amp; config. :: :: Parse Hour &amp; 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 removing unwated charachters / or - depends on system installation for /F 'usebackq tokens=1,2,3 delims=/-' %%i in ('%DATE%@') do set Tdate=%%i%%j%%k :: set TimeStamp=%Tdate%%HR%%MIN% :: we now have a string which will appear as 12052009@0112 :: :: -- :: Backup the MySQL DB from Live System :: OpenSim Database Backup Section :: -- :: for more information on commands used: :: Open a command shell (DOS Prompt / Console Session) :: Go to the MySql Installation Folder :: NOTE that the output can be reditected into a TXT file so that you can read it in a Text Editor :: Type the Following commands for information at the command prompt :: mysqldump -? :: mysqlshow -? :: to redirect out to TXT file do as shown: :: mysqldump -? &gt; %OSbackup%\MySqlDump_Commands.txt :: mysqlshow -? &gt; %OSbackup%\MySqlShow_Commands.txt :: !!! Target Folder must exist. Adjust Paths according to YOUR installation !!! :: - :: make folder if not exist if not exist %OSbackup%\DBsql\*.* md %OSbackup%\DBsql :: :: generate MySql DB Backup if DBUSER NEQ XXX mysqldump --opt -u%DBUSER% -p%DBPW% %DBNAME% &gt; %OS_Instance%\BACKup\DBsql\%DBNAME%_%TIMESTAMP%.sql :: :: Dump the opensim table struct info for a snapshot of the stats if DBUSER NEQ XXX mysqlshow -v -v -u%DBUSER% -p%DBPW% %DBNAME% &gt; %OSbackup%\DBsql\OS_db_STATS.txt :: :: ========================= :: END OF MySql DB Backup Section :: ========================= :: :: OPENSIM SYSTEM DATA BACKUP SECTION :: cd %OSbackup% :: :: if the folders do not exist, create them :: if not exist %OSbackup%\DB\*.* md %OSbackup%\DB if not exist %OSbackup%\INI\*.* md %OSbackup%\INI if not exist %OSbackup%\EXPORTS\*.* md %OSbackup%\EXPORTS 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 THE FILES OVER -- 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% %OSbackup%\LOGS *.log /LOG:%OSbackup%\LOGSlog.txt robocopy %OSbinSrc%\Regions %OSbackup%\REGIONS *.* /S /LOG:%OSbackup%\REGIONSlog.txt robocopy %OSbinSrc% %OSbackup%\TXT *.txt /S /LOG:%OSbackup%\INIlog.txt robocopy %OSbinSrc% %OSbackup%\OAR *.tar.gz /S /LOG:%OSbackup%\OARlog.txt robocopy %OSbinSrc% %OSbackup%\TERRAINS *.r32 /S /LOG:%OSbackup%\TERRAINSlog.txt :: cd %OSbackup%\LOGS RENAME opensim.log OSLOG_(%TimeStamp%).log :: :END"