Including Custom Databases in the Backup BizTalk Server Job

I’m sure its common knowledge that other databases can be backed-up using the Backup BizTalk Server Job, meaning that the transaction consistency that is that is written the the BizTalk databases can be included in your own custom databases.

I thought it was pretty easy to include custom databases, simply by adding an entry into the adm_OtherBackupDatabases table in the BizTalkMgmtDb database. In the screenshot below, I’ve added the BizTalk RosettaNet Accelerator (BTARN) databases:

I thought it was that simple, until I tried it for the first time in real life and was greeted with the following error from SQL Agent (notice the error in bold):

Executed as user: NT AUTHORITYSYSTEM. Processed 17520 pages for database ‘BizTalkDTADb’, file ‘BizTalkDTADb’ on file 1. [SQLSTATE 01000] (Message 4035)  Processed 2 pages for database ‘BizTalkDTADb’, file ‘BizTalkDTADb_log’ on file 1. [SQLSTATE 01000] (Message 4035)  BACKUP DATABASE successfully processed 17522 pages in 10.454 seconds (13.093 MB/sec). [SQLSTATE 01000] (Message 3014)  Processed 2264 pages for database ‘BizTalkMgmtDb’, file ‘BizTalkMgmtDb’ on file 1. [SQLSTATE 01000] (Message 4035)  Processed 3 pages for database ‘BizTalkMgmtDb’, file ‘BizTalkMgmtDb_log’ on file 1. [SQLSTATE 01000] (Message 4035)  BACKUP DATABASE successfully processed 2267 pages in 2.284 seconds (7.751 MB/sec). [SQLSTATE 01000] (Message 3014)  Processed 3280 pages for database ‘BizTalkMsgBoxDb’, file ‘BizTalkMsgBoxDb’ on file 1. [SQLSTATE 01000] (Message 4035)  Processed 2 pages for database ‘BizTalkMsgBoxDb’, file ‘BizTalkMsgBoxDb_log’ on file 1. [SQLSTATE 01000] (Message 4035)  BACKUP DATABASE successfully processed 3282 pages in 2.156 seconds (11.890 MB/sec). [SQLSTATE 01000] (Message 3014)  Processed 256 pages for database ‘BizTalkRuleEngineDb’, file ‘BizTalkRuleEngineDb’ on file 1. [SQLSTATE 01000] (Message 4035)  Processed 1 pages for database ‘BizTalkRuleEngineDb’, file ‘BizTalkRuleEngineDb_log’ on file 1. [SQLSTATE 01000] (Message 4035) Could not find stored procedure ‘BTARNARCHIVE.dbo.sp_BackupBizTalkFull’. [SQLSTATE 42000] (Error 2812) BACKUP DATABASE successfully processed 257 pages in 0.326 seconds (6.158 MB/sec). [SQLSTATE 01000] (Error 3014).  The step failed.

‘Could not find stored procedure ‘BTARNARCHIVE.dbo.sp_BackupBizTalkFull’. Oh really?

It turns out that it isn’t as simple as adding a custom database to the adm_OtherBackupDatabases table – a number of stored procedures and tables also need to be added to your custom database to get the backup job to successfully work, however these can be easily added by executing the two SQL scripts Backup_Setup_All_Procs.sql and Backup_Setup_All_Tables.sql against your custom databases (the scripts can be found in the ‘[BizTalk Installation Directory]Schema’ directory). You may want to force a full backup to ensure you have full backups across all of your databases:

BEGIN TRAN
UPDATE [BizTalkMgmtDb].[dbo].[adm_ForceFullBackup] SET ForceFull = 1
COMMIT TRAN

Re-run your backup job and you will see your custom databases included in the backup.

The requirement to include additional stored procedures and tables in custom databases is well worth remembering, especially if you are deploying (or re-deploying) custom databases that don’t include these artifacts by default.

The procedure is detailed in more depth on MSDN.

BTARN ‘Service Content’ Error in the RNDisAssembler Component

We came across the following error late last night which was a bit of a show-stopper. We were trying to load a custom PIP (specifically a PIDX OrderChange), but kept hitting this issue time and time again:

Event Type: Error
Event Source: BizTalk Accelerator for RosettaNet
Event Category: None
Event ID: 4096
Description:
Source module:
RNDisAssembler
Correlation information:
Description:
Receive pipeline rejected incoming message
due to the following RNIF exception:
UNP.SCON.VALERR : A failure occurred while validating the service content.
Details:
Event Type: ErrorEvent Source: BizTalk Accelerator for RosettaNetEvent Category: NoneEvent ID: 4096Date: 18/08/2010Time: 10:33:47User: N/AComputer: [COMPUTER NAME]Description:Source module:RNDisAssembler
Correlation information:

Description:

Receive pipeline rejected incoming message due to the following RNIF exception: UNP.SCON.VALERR : A failure occurred while validating the service content.
Details:

At first I didn’t quite understand the cause of the error – the PIDX OrderChange message contained within the Service Content was valid (as far as I was aware), all of the other messages within the payload looked correct and it was 3am….

It turns out that the RNDisassembler does in-fact attempt to validate the message contained within the Service Content against a deployed schema just like the standard XmlDisassembler. The message that our trading partner was sending did not validate and hence the RosettaNet Accelerator threw this error message; once we had corrected the schema and redeployed, the error went away.

This is certainly one to be aware of if you are developing custom PIP’s to use with the RosettaNet Accelerator: ensure that the message in the Service Content validates against your custom PIP schema!

SCOM can cause Unchecked Growth in SSODB

Ok, that’s a bit of an attention grabbing headline, so let me clarify that statement: SCOM can cause unchecked growth in SSODB if you’re not regularly backing up the SSODB transaction log.

We encountered this one today – a client’s SSODB ran out of space overnight, causing the BizTalk environment to shut-down. On further investigation, it would appear that every time SCOM checks the health of Enterprise Single Sign-On, an entry is recorded in the SSOX_AuditXpLookup table:

ESSO appears to be clever enough to manage the size of this table, truncating it every 30 minutes, however this doesn’t help if you’re not managing the size of the database transaction log through backups. To quote the SQL Server documentation:

If log records were never deleted from the transaction log, it would eventually fill all the disk space that is available to the physical log files. Log truncation automatically frees space in the logical log for reuse by the transaction log.

All the more reason to enable and run the supplied Backup BizTalk Server job to help maintain the health of your BizTalk environment.

If you’re looking for more information on the Backup BizTalk Server Job, take a look at my series of posts on the topic: http://www.modhul.com/2009/06/29/configuring-biztalk-for-disaster-recovery-part-1/

Hat-tip to this MSDN Forums posting that helped us identify the issue.

Team Explorer 2010 ‘narks’ Enterprise Single Sign-On

Update 20th July 2010: There is now a Hotfix from Microsoft that resolves this issue, see http://support.microsoft.com/kb/2252691; thanks for the pointer Daniel.

If you’re developing BizTalk projects and using TFS 2010, you’ll probably need to install Team Explorer 2010 to leverage some of the new functionality not accessible through the Visual Studio 2008 TFS hooks. Team Explorer 2010 is a stripped down version of the Visual Studio 2010 environment used solely to access Team Foundation Server services.

Be aware that if you do install Team Explorer 2010, you’ll nark your Enterprise Single Sign-On installation, meaning you can’t make any changes to BizTalk – when ESSO attempts to start, you’ll probably receive the following error in the Application Event Log:

Could not create SSOSQL. To fix the problem, reinstall SSO or try 'regasm SSOSQL.dll' from a Visual Studio command prompt.
Error Code: 0x80131700
To correct the missing SSOSQL assembly, simply run the following command in a Visual Studio command prompt as suggested:
regasm "C:Program FilesCommon FilesEnterprise Single Sign-OnSSOSQL.dll"
ESSO should now start as expected.

Accouncing the New BizTalk Message Archiving Pipeline Component

It gives me great pleasure to announce Version 1.0 of the BizTalk Message Archiving Pipeline Component and my new venture, Atomic-Scope.

The component allows you to archive Xml, flat-file, EDI and binary messages as they pass thru receive and send pipelines, without the need for complex ‘archiving’ Send Port configurations, additional load on the MessageBox database and requires zero developer time – just plug-in, configure and use! Archive filenames are created at runtime from Context-Properties written to the message by receive adapters, custom properties defined in your solution or with the standard Send Port ‘macros’. A free 14-day trial is available – download your copy now.

This new version of the component builds on the excellent feedback received following the launch of the original version on Codeplex and has spent many months in development – this release is a complete re-write and incorporates many of the community requested features, including:

  • The ability to enable and disable the component at runtime;
  • The promotion of the archive filename into the Message Context for use in orchestrations, Send Port filters etc.;
  • Full streaming support, even for messages that fail when being processed by downstream components (such as flat-file or EDI messages);
  • Support for a wide-range of adapter Context-Properties ‘out-of-the-box’ and custom, user-defined Context-Properties;
  • Native 32- and 64-bit versions;
  • Support for all versions of BizTalk Server 2006, BizTalk Server 2006 R2 & BizTalk Server 2009;

The component is also backed by our business-class Enterprise Support Agreement. You can also read more about Atomic-Scope and see how we are supported by the Microsoft BizSpark Programme.

A short video if available which gives an overview of how the component works when archiving files in receive pipelines (opens in a new window):

I plan on posting more information about the Message Archiving Component over the coming weeks. In the meantime, why not download the component and try it out yourself?

Applying BizTalk Hotfixes – Guidelines for Administrators

Microsoft Support have just a published a helpful support article discussing some of the general guidelines that need to be followed when applying BizTalk Server Hotfixes, applicable to all versions from BizTalk Server 2004 onwards.

The article covers some of the more salient points we need to remember as BizTalk Adminstrators, including:

  • Considerations when installing Hotfixes on 32-bit and 64-bit servers;
  • Considerations when installing Hotfixes in a multi-server BizTalk Group;
  • Considerations when un-installing or rolling-back Hotfixes, including how to roll-back SQL scripts.
  • Restart requirements after installing Hotfixes;

The ‘Information on BizTalk Server Hotfixes’ article can be found on Microsoft’s Support Site. Well worth a read.

Reblog this post [with Zemanta]

BizTalk DR: Configuring BizTalk Backup for Disaster Recovery – Part 2

Originally posted by Nick Heppleston at: http://www.modhul.com/2009/09/04/configuring-biztalk-backup-for-disaster-recovery-part-2/

This is the second of a three-part series covering the BizTalk Backup Process, where I’m looking at one of the two supported methods to backup and restore a BizTalk Server environment – Log Shipping. The series will cover the following topics:

  • In Part 1, I’ll provide a high-level overview of the backup and restore process. Part 1 is already published, go an read it now!
  • In Part 2, I’ll walk through an actual backup and restore setup, looking at the configuration steps as we go.
  • In Part 3, I’ll demonstrate a long-running BizTalk application that is restored on a sample disaster recovery environment using the backup and restore process configured in Part 2.

Please accept my apologies for the wide screenshots in this part of the series. Please also note that I have not repeated the configuration steps on the MSDN website – this is an excellent resource and I do not wish to repeat or plagarise this work. In this part of the series, I have simply added my own observations that I thought were lacking from the MSDN text.

BizTalk Log Shipping – A Quick Recap

Before we look at how the BizTalk Log Shipping process is configured, let us quickly recap on the process; for a more detailed overview, I recommend that you read Part One of this series of blog posts, specifically the section which covers The Backup and Restore Process.

The backup and restore process (BizTalk Log Shipping) is as follows:

  • The BizTalk Backup SQL Agent Job creates data and transaction-log backups from the production environment, placing log marks into the transaction-log backups. An audit table is maintained which lists the backups that have been created, the type of backup (data or transaction-log backup) and details the location of the backup files. The physical data- and log-files are then pushed to a UNC share, as shown below:

BizTalk Backup Process Overview

  • The standby environment reads the audit table maintained by the production environment, using this information to determine which data- and transaction-log files need to be restored. These files are restored from the UNC share using the SQL ‘NORECOVERY’ option, leaving the databases in a non-operational state, allowing additional transaction-logs to be applied. Note: the transaction-logs are not restored to the transaction-log mark in this step, instead the full transaction-log is restored:

BizTalk Backup Process Overview

These two steps continue throughout live operations. In the event of a disaster recovery situation, where the production environment has been lost and the standby environment needs to be brought online, three recovery steps must be performed on the standby environment:

  • The most recent transaction-log backup is restored to its transaction-log mark using the SQL ‘WITH RECOVERY’ option, placing the databases into an operationally ready state.
  • Database and registry updates statements are run to re-configure the restored databases to use the standby environment.
  • BizTalk services are brought online (including the Enterprise Single Sing-On server and Business Rules Engine service etc.) and the standby environment is made live as the production environment.

Once the live environment is recovered and the switch from the standby environment back to the live environment is ready to be made, the process is reversed, with the standby environment creating backups that are restored to the live environment.

In this post, we’ll look at how to configure each of these steps.

BizTalk Log Shipping – Prerequisites

Several prerequisites need to be setup before configuring BizTalk Log Shipping. I would recommend that you spend time to ensure that these areas work, as they will save you a great deal of pain when configuring log shipping. They include:

  1. Before starting to configure the BizTalk Log Shipping process, ensure that the production and standby servers can communicate with each other over the network;
  2. The production and standby SQL Server instances need to communicate with each other via MSDTC (Microsoft Distributed Transaction Coordinator). There are a number of excellent resources on the internet addressing MSDTC configuration issues including Troubleshooting Problems with MSDTC on the MSDN website. Ensure that the two serverscan communicate over MSDTC before starting to configure Log Shipping;
  3. The BizTalk backup and restore SQL Agent jobs should run as under an isolated user account – choose a Windows user account for this purpose and create a SQL Server login for this account. Map this SQL Server login to the BTS_BACKUP_USERS database role in the BizTalk Server databases; and finally
  4. It is recommend that the data- and transaction-log backup files are written to a highly-available UNC share. Ensure that an UNC share is created that is accessible by both the production and standby servers and that the necessary permissions are assigned. Check that you can read, write and delete files from this share using Windows Explorer on both  servers.

Configuring The Backup Job

The first task in configuring BizTalk Log Shipping is to configure the SQL Agent ‘Backup BizTalk Server (BizTalkMgmtDb)’ backup job on the production environment. This job is created by the BizTalk installer and is responsible for a number of tasks, including:

  • Creating a full database backup at the specified interval;
  • Writing a transaction-log mark to the transaction-log and creating a backup of the transaction-log; and finally
  • Clearing the backup history table, based on specified criteria.

To configure the job, follow the instructions detailed in the excellent How to Configure the Backup BizTalk Server Job on the MSDN website.

When configuring the backup job, remember the following:

  • The Frequency parameter denotes the frequency at which a full backup is taken. By default, this is set to d (daily) which is sufficient for most BizTalk environments. If you require more frequent full backups, change this accordingly – other values include h (hourly), w (weekly), m (monthly), or y (yearly). Note that irrespective of what frequency you set here, transaction log backups will occur every time this job is run.
  • The (optional) Force full backup after partial backup failures parameter instructs the backup job to create a full backup if a transaction-log backup failed the last time the job ran, ignoring the Frequency setting. For example, if you use a setting of ‘daily’ for the Frequency parameter and the job fails to create a full set of transaction-log backups, the next time the job runs, it will create a full-backup followed by a further transaction-log backup; a second full-backup followed by a transaction-log backup will be created when the job runs again at midnight (UTC time) to honour the Frequency setting.
  • When setting the Location of backup files parameter, ensure that the user who is running this SQL Agent job has sufficient privileges to write to that location.

By default, this job runs once every fifteen minutes; this means that a transaction-log backup will be created and restored once every fifteen minutes (once you have configured the log shipping restore jobs, which execute once every minute). If you want to reduce delay in restoring these transaction-logs to your standby environment, reduce the scheduled frequency of the backup job. I would however recommend that this job is run no more frequently than once every three minutes; you will however need to find a happy medium that works best in your environment – this will be based on the load on your BizTalk Server and the rate at which your SQL Server transaction-logs grow.

Once you have configured the backup job, execute it starting at step one and ensure you have backup data- and log-files in your UNC share location, and entries in the BizTalkMgmtDb.dbo.adm_BackupHistory table, as follows:

BackupHistory

These entries in the Backup History table will be read by the restore jobs on the standby SQL Server and used to identify which data and log files need to be restored. Of particular interest in the above screenshot of the Backup History table are the following columns:

  • The BackupSetId column, which is used during the restore to identify an entire backup-set;
  • The MarkName column, which details the Transaction-Log Mark Name given to transaction-logs (Notice how the full database-backup has a value of NULL instead of a a log mark name, as these cannot be applied to full backups);
  • The BackupFilename and BackupFileLocation columns, which are used by the restore jobs to locate the data- and log-files to restore;
  • The BackupType column, which is used by the restore jobs to identify the type of backup the backup set relates to; and finally
  • The SetComplete column, which is used by the (optional) Force full backup after partial backup failures parameter of the backup job to determine whether a full or partial backup was taken during the last execution.

One final point to note about the ‘Backup BizTalk Server (BizTalkMgmtDb)’ backup job: if the SQL Agent Service or the backup-job is disabled and misses the time-window in which the full-backup should be taken (based on the Frequency parameter), the next execution of the job will cause a full backup to be created. For example, if you use a setting of ‘daily’ for the Frequency parameter and the job is disabled between 2000 and 0200 (i.e. during the time window that the daily full-backup will occur – 0000UTC), when the job is enabled, it will detect that its ‘frequency’ has been missed and cause a full-back to be created, followed by a transaction-log backup.

Forcing a Full Backup

There may be cases where you wish to perform an ad-hoc full-backup, outside of the Frequency window specified in Backup BizTalk Server SQL Agent Job – for example, you may want to take a full backup before applying a hotfix or service pack, or when replacing hardware.

When a backup is forced, the Frequency window is ignored next time the Backup BizTalk Server job executes and both data- and log-file backups are generated. If a problem occurs in the scenarios described above and the databases need to be recovered, only one transaction log needs to be restored for each database, reducing the recovery time significantly.

To force a full backup, execute the BizTalkMgmtDb.dbo.sp_ForceFullBackup stored procedure; the next time the Backup BizTalk Server job executes, both data- and log-file backups will be generated.

Configuring BizTalk Log Shipping – The Restore Jobs

We’re now ready to configure the standby environment to automagically restore our data- and log-file backups that are created by our production environment.

Several new jobs will be created in the standby SQL Server environment to handle the restoring of backups (along with a number of tables and stored procedures in the master database, which are used to hold information about the Log Shipping process). The jobs in particular are responsible for a number of tasks, including:

  • Retrieving the backup history from the production environment;
  • Restoring the data- and transaction-log backup files to the standby SQL Server in a non-operational state, allowing further transaction-logs to be restored; and finally
  • Restoring all of the databases to an operational state, by restoring the next available transaction-log to their last log mark only when disaster recovery is invoked and the standby SQL Server environment is to be made operational.

For more detailed information on these jobs, I recommend that you read the first part of this series, specifically the section which covers the Restore Process and the BizTalk Log Shipping Jobs.

To configure log shipping on the standby environment, follow the instructions detailed in the excellent How to Configure the Destination System for Log Shipping on the MSDN website.

When configuring the backup job, remember the following:

  • The standby environment will try and read the data- and log-files from the same location as they were written to by the backup job; it is therefore prudent to use a UNC share location (mapped to a drive letter if necessary) that both the standby and production environments have read/write permissions to.
  • If you encounter problems executing the bts_ConfigureBizTalkLogShipping stored procedure, ensure that you have correctly configured MSDTC between the production and standby environments; additionally, check that you have enabled Ad Hoc Distributed Queries on the standby SQL Server (if using SQL Server 2005/2008) as this stored procedure executes distributed queries over a linked server to the production SQL Server.
  • If you need to re-configure your standby environment, re-run the configuration process including starting with the LogShipping_Destination_Schema.sql and LogShipping_Destination_Logic.sql before executing the bts_ConfigureBizTalkLogShipping stored procedure.

A note about the Physical Location of Database Files when Restoring

If you have been around SQL Server for any length of time, you will have come across some of the more ‘helpful’ features of restoring data- and transaction-log files – when you restore a backup, SQL Server will attempt to re-create the database on the standby environment in exactly the same directory structure as the data- and log-file/s appeared on the production SQL Server.

If the directory structure doesn’t exist on the standby server exactly as it did on the production server, you will receive an error similar to the following and the restore will fail:

Executed as user: BIZTALKDRBizTalkBackup. Directory lookup for the file “D:MSSQL.4MSSQLDATABizTalkMgmtDb.mdf” failed with the operating system error 3(The system cannot find the path specified.). [SQLSTATE 42000] (Error 5133) File ‘BizTalkMgmtDb’ cannot be restored to ‘D:MSSQL.4MSSQLDATABizTalkMgmtDb.mdf’. Use WITH MOVE to identify a valid location for the file. [SQLSTATE 42000] (Error 3156) Directory lookup for the file “D:MSSQL.4MSSQLDATABizTalkMgmtDb_log.LDF” failed with the operating system error 3(The system cannot find the path specified.). [SQLSTATE 42000] (Error 5133) File ‘BizTalkMgmtDb_log’ cannot be restored to ‘D:MSSQL.4MSSQLDATABizTalkMgmtDb_log.LDF’. Use WITH MOVE to identify a valid location for the file. [SQLSTATE 42000] (Error 3156) Problems were identified while planning for the RESTORE statement. Previous messages provide details. [SQLSTATE 42000] (Error 3119) RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.

There are a number of ways we can resolve this, including using the WITH MOVE statement, as suggested in the error text, however this would require us to make changes to the stored procedure that is invoked by the Restore Databases SQL Agent job – this would invalidate our warranty with Microsoft as changes to the SQL Server portion of the codebase are not supported.

SQL Server uses several techniques to determine the physical location that databases should be restored to (further information can be found in Microsoft Knowledgebase Article 221465); the easiest method is to perform an implicit ‘MOVE’ – if the database already exists on the standby environment, but at a different location than specified in the backup set, the location on the server is used during the restore.

I would therefore recommend that you create the various BizTalk databases (including the Business Rules Engine Db and SSO Db) in their correct locations on the standby environment before you enable the restore job, this way SQL Server will restore the databases to your preferred location.

Testing the Restore Functionality

With log shipping successfully configured, enable the BTS Log Shipping – Get Backup History (DBServer: “[Database Server Name]”, DBName: “[Database Name]”) SQL Agent job to retrieve backup history information from the production environment.

If everything is configured correctly, you will see entries in the standby SQL Server master.dbo.bts_LogShippingHistory table which show the backups that are yet to be restored (see the Restored and RestoredDateTime columns highlighted in Green). In the following screenshot, there is one full database backup, plus three transaction-log backups to be restored.

LogShippingHistory-DatabasesToBeRestoredv2

With the backup history successfully retrieved from the production environment, we’re now ready to start restoring the data- and log-files to our standby environment.

Enable the BTS Log Shipping – Restore Databases (DBServer: “[Database Server Name]”, DBName: “[Database Name]”) SQL Agent job. As described in the first post of this series, this job restores the BizTalk databases to a non-operational state, allowing further transaction-logs to be restored. The job uses the  ‘NORECOVERY’ option, leaving each database in the ‘Restoring…’ state, thereby allowing additional transaction-logs to be applied.

In the screenshot below, the Restore Databases job has been enabled and has executed, restoring the full backup set (BackupType ‘Db’) and two transaction-log backup sets (BackupType ‘Lg”) as highlighted in Green; the transaction log set that has not been restored – highlighted in Orange – is the N-1 backup-set that is only restored when the standby environment is to be brought online as the new production environment; this is to ensure that we always have one transaction-log that can be restored to the transaction-log mark. Also note that the RestoredDateTime column is populated with the UTC time, not the actual system time.

LogShippingHistory-RestoredDatabasesv2

One final point to take away when restoring databases is the way in which the restore job handles full backups (BackupType ‘Db’). If the production environment creates a full backup – either because the Backup job has crossed its Frequency window, or the BizTalk Administrator has forced a full backup – the Log Shipping Restore job will only restore the transaction log created during the full backup – it skips the data-file backup as this isn’t required to maintain database integrity. As demonstrated in the screenshot below, the transaction logs before and after the full backup have been restored (highlighted in Green), however the data-file backup hasn’t been restored (highlighted in Purple); finally, the N-1 transaction log set is yet to be restored (highlighted in Orange):

LogShippingHistory-RestoredDatabasesFullBackupNotRestored

Cleaning the Standby Environment

You may want to clean the standby environment without performing a full reconfiguration of BizTalk Log Shipping, so that the restore process starts from scratch: the databases are re-created and restoration starts as if it is the first time it has run.

To achieve this, execute the master.dbo.bts_LogShippingClean stored procedure on the standby environment. This stored procedure deletes all references to the previously restored backup-sets and physically deletes the databases that are in the ‘restoring’ state. The bts_LogShippingClean stored proc accepts a single parameter @SourceId; the value you should use for this  parameter is based on your log shipping configuration which is available in the master.dbo.bts_LogShippingDatabases table, an example of which is shown below:

CleanupLogShipping-SourceId

These two actions force the BTS Log Shipping – Restore Databases job to re-create the databases in a restoring state by applying the last full backup, followed by subsequent transaction log backups the next time it runs. This is demonstrated in the screenshot below – the data-file and transaction-log backups are restored (highlighted in Green), with the N-1 transaction log set is yet to be restored (highlighted in Orange); also notice how the full- and transaction log backups are restored sequentially at the same time, within a few seconds of each other (see the RestoredDateTime column):

LogShippingHistory-LogShippingCleanFullBackupRestored

Handling Partial Backup-Sets

One of the most common errors I encountered while putting together this series of blog posts related to partially restored backups-sets. The SQL Agent BTS Log Shipping – Restore Databases job automagically detects this condition and raises an error in the Event Log similar to the following:

Executed as user: BIZTALKDRSqlAgent. A partial set has been detected but a valid full backup set does not exist yet.  Please force a full backup on the source server. [SQLSTATE 42000] (Error 50000)  @LastSetId: 487 [SQLSTATE 01000] (Error 0)  @RestoredToMark: 0 [SQLSTATE 01000] (Error 0)  Here101 [SQLSTATE 01000] (Error 0)  @NextSetId: 488 [SQLSTATE 01000] (Error 0)  Here102 [SQLSTATE 01000] (Error 0)   [SQLSTATE 01000] (Error 0)  Statement2: 1 [SQLSTATE 01000] (Error 0)  Statement3: 1 [SQLSTATE 01000] (Error 0).  The step failed.

The restore job identifies this error condition by simply checking for a backup set that has both restored and non-restored entries, as shown in the screenshot below (highlighted in Orange):

LogShippingHistory-PartialRestore

When a partially restored backup-set is detected, the restore job will attempt to identify and restore a more recent full data- and transaction-log backup, thereby minimizing the synchronization gap between the production and standby environments. If a more recent full backup cannot be found, the job will fail reporting the error detailed above and either wait until a new full backup is created as the backup job passes its Frequency window, or when the BizTalk Administration forces a full backup.

Wrap-Up

So that’s the end of Part 2. We’ve walked through configuring the backup and restore jobs and looked at how to check that these jobs are working correctly, how to force full backups and problems caused by partial restores.

In Part 3, we’ll demonstrate a long-running BizTalk application that is restored and brought operational on a standby environment using the instructions detailed here.

Postscript: Creating a Sandbox Environment to Test Log Shipping

Before jumping into configuring Log Shipping on a production environment, I would suggest that you become familiar with how the process itself works, either in a test or sandboxed environment. In writing this series of blog posts, I created a small VirtualBox based virtual-machine sandbox with which I could test the various scenario’s I planned on writing about. This sandbox consisted of:

  • A ‘production’ server hosting BizTalk and the BizTalk databases in an operational state;
  • A ‘standby’ server hosting BizTalk and the restored BizTalk databases;
  • A standalone server acting as an Active Directory Domain Controller.

All three servers communicate through a private VirtualBox network and cannot be seen outside of the physical host machine. The ‘production’ and ‘standby’ servers run Windows Server 2008, plus BizTalk Server 2009 and SQL Server 2008 (all Enterprise Edition), running with 512Mb RAM; the AD server runs Windows Server 2008 Core, running with 256Mb RAM. All three virtual-machines run extremely well given their small amount of RAM, however they need to be located on a separate HDD to the physical machine’s OS otherwise heavy I/O thrashing causes a significant degradation in performance.

Reblog this post [with Zemanta]