Monday, June 1, 2009

How to use OSQL osql command-line tool to backup and restore MSDE Database - How to bring Standby BES server online

Issue: Production BES 4.1 SP6 server failed.

Solution: Fortunately we have a standby BES 4.1 SP6 running.we used the osql command-line tool to backup Production BES MSDE database with Windows scheduler every 30 minutes and xcopy the BESMGMT Database to multiple servers and we were able to bring the standby BES online within minutes with no interactive response from BB client end.

You can use the osql command-line tool to access, query, or run scripts against, your SQL Server or MSDE database. For example, to backup your ENT Server databases you could run the following from the command line:

osql -S BES01 -E -Q " BACKUP DATABASE BESMGMT TO DISK = 'C:\Temp\BES01-BESMGMT.bak' with init"

  • -S BES01 specifies the server name to be "BES01" For a database on the local machine, specify either "(local)", or "(local)\[InstanceName]" if you are using a named instance.
  • -E specifies that osql should use a trusted connection. You could instead specify a username using the -U option.
  • -Q specifies that oSQL should execute the SQL query that follows in double-quotes and then exit
  • BACKUP DATABASE BESMGMT TO DISK = 'c:\Temp\' this is the actual query that will get exexuted... as you can see this simply backs up the BESMGMT database to the file C:\Temp\BES01-BESMGMT.bak.
  • "with init" to tell osql backup to overwrite the existing backup file to save your disk space.

Similary, to restore the above backup you could run the following from the command line on Standby BES server:

osql -S BES02 -E -Q " RESTORE DATABASE BESMGMT FROM DISK = 'C:\Temp\BES01-BESMGMT.bak' "

After you successully restore your MSDE database, Disconnect your old Production server network cable, and start your all BES related services on your Standby BES server. Please see RIM doucumentation on how to setup BES 4.X standby BES.

Note: with BES 5.0, RIM has HA solution for BES.


1 comment: