Microsoft BizTalk Server 2004 Log Shipping Feature for SP1

November 16, 2004

**********************************************************************

© 2004 Microsoft Corporation. All rights reserved.

**********************************************************************

These release notes contain important information about the release of the Microsoft® BizTalk® Server 2004 Log Shipping feature included with SP1.

You should have a working knowledge of the log shipping implementation in Microsoft® SQL Server™ and familiarity with the full recovery model and log restoration process in SQL Server. For more information about these features, see SQL Server Books Online.

The following information is covered in this document:

Overview

Setup Instructions

Files Added or Changed by Log Shipping

Restore History

Source System Recovery

Troubleshooting

About BizTalk Server 2004 Log Shipping

The Microsoft® BizTalk® Server 2004 Log Shipping (Log Shipping) feature for SP1 extends the existing Backup BizTalk Server SQL Agent job provided with BizTalk Server 2004. Log Shipping eliminates the need to manually restore a series of backup sets produced by the backup job, and reduces downtime in the event of a system failure.

Due to the distributed database design of BizTalk Server 2004, when you produce backups you must be certain to provide a consistent point to which the backups can be restored. Transactions can span multiple databases; if one database goes offline and must be restored, then all related databases must be restored to a single point in time to ensure that the system is in a consistent state.

Note   Not all databases participate in distributed transactions. For more information, see "Backing up your databases" in BizTalk Server 2004 Help.

The Backup BizTalk Server job uses Microsoft® SQL Server™ log marking to provide an automated process that produces database backup sets. These sets include synchronized points that are used during the restore process. As part of the process of restoring a set of databases produced by the Backup BizTalk Server job, the last log backup file for each database is restored to a specific log mark. When the SQL Server implementation of log shipping is applied to BizTalk Server databases, there is no final log to restore to the mark.

To keep an outstanding log backup set, Log Shipping does not restore the most current log backup set. In the event of a system failure, you must manually restore the most current log backup set to the log mark in order to provide a consistent database environment.

Back to Top

Setup Instructions

After you install Microsoft® BizTalk® Server 2004 SP1, you must configure Log Shipping and modify both the source and destination system.

Configuring Log Shipping

Log Shipping works in both single server and distributed server environments. The server or group of servers that is live is known as the source system. The server or group of servers that will be used to restore the database backups produced by the source system is known as the destination system. You must make modifications to both the source and destination systems in order to enable Log Shipping.

Modifying the source system

For the purposes of Log Shipping, it does not matter if the source system is located on a single server or if it is distributed among multiple servers. There are no additional considerations other than those required to successfully run the Backup BizTalk Server job.

To modify the source system

  1. Open SQL Server Enterprise Manager and connect to the server that holds the BizTalk Server Configuration database (BizTalkMgmtDb).
  2. In Enterprise Manager, right-click the Backup BizTalk Server Job and open the Properties dialog box.
  3. On the Steps tab, select the BackupFull step and click the Edit button.
  4. In the Command text box. add the following parameter to the end of the parameter list in the call to the sp_BackupAllFull stored procedure: , 1

    The text in the Command window should now look as follows:

    EXEC [dbo].[sp_BackupAllFull_Schedule]    'h' /* Frequency */,
                    'BTS' /* Name */, 
                   '\\BackupShare' /* location of backup files */, 
                   1 /* 1 to force full backups after backup failures*/
    Note   This is optional and configures the job to automatically create full backups when failures are detected. To disable this feature set the parameter to 0 or remove the parameter completely.
  5. On the Steps tab, select Clear Backup History, and click Edit to set the number of days to retain backup history.
    Note   The default value is 14 days.
  6. If this is the first time running Backup BizTalk Server job, set the destination path where you will store backup files.
  7. Manually run the job and confirm the following:
  8. Enable the Backup BizTalk Server job.

Modifying the destination system

Use the following instructions to create a destination environment that consists of one server for a single source system. If the destination environment contains multiple servers, repeat the steps on each destination server.

To modify the destination system

  1. Open SQL Server Enterprise Manager and link the destination server to the source server that holds the BizTalk Server MgmtDb database.
  2. If it is not already running, open Query Analyzer and connect to the destination server.
  3. Run the following SQL scripts:

    <install directory>\Schema\LogShipping_Destination_Schema.sql

    <install directory>\Schema\LogShipping_Destination_Logic.sql

  4. Insert a row into the bts_LogShippingSource table for the given source:
    Column Name Data Type Description
    SourceId Int Creates an ID for the source system. Any number will work. This is used to identify the source for all operations.
    SourceDesc nvarchar(256) Description of the source system.
    MgmtDatabaseName Sysname Name of the Mgmt database for the source system.
    MgmtServerName nvarchar(256) Name of the source system server that holds the Configuration database (BizTalkMgmtDb).
  5. Insert rows into the newly created bts_LogShippingDatabases table for the new source system (one row for each source database to be restored on this destination server):
    Column Name Data Type Description
    SourceId int ID for the source system to which the database belongs.
    DatabaseId int ID for the database. This can be any unique integer. It does not have to be the system database ID.
    DatabaseName sysname Name of the database in the source system.
    ServerName nvarchar(256) Name of the source server where this database lives.
    LogFileLocation nvarchar(1500) Location of the log backup files. If null, bts_LogShippingHistory.BackupFileLocation is used as the default.
    DBFileLocation nvarchar(1500) Location of the full database backup files. If null, bts_LogShippingHistory.BackupFileLocation is used as the default.
    RestoreName sysname Name to use when restoring the database. If null, the original source database name is used.
  6. Open the LogShipping_DestinationJobs.sql script located in <install directory>\Schema\.
  7. Modify the script by setting the @SourceId variable to the SourceId value created in step 5 above.
  8. Run the modified script against the BizTalk Server Configuration database (BizTalkMgmtDb).
  9. Open SQL Server Enterprise Manager and connect to the destination server.
  10. Select Management\SQL Server Agent\Jobs.
    Note    Two new jobs have been created:
  11. You can adjust the schedules as needed for both jobs by accessing the Properties dialog box for the job. Then, on the Schedules tab, click the Edit button.
  12. Enable both BizTalk Server Log Shipping Get Backup History (SourceId x) job and BizTalk Server Log Shipping Restore Databases (SourceId x) job.

Bringing a Destination System Online

This section assumes a good understanding of the process of manually restoring backups produced by the Backup BizTalk Server job. For more information, see "Restoring your databases" in the BizTalk Server 2004 Help.

If there is only one server in the destination environment, make sure that all of the log backup sets (except for the most recent set) have been restored. For more information, see Viewing Restore History and Restore History Gaps. If all the log backup sets have not been restored, and the restore job is not currently running, run the restore job (manually if necessary). If there are outstanding backup sets that can be restored, the job will process them until they are all restored.

When all of the backup sets have been restored, manually restore all of the log files in the last backup set using the STOPATMARK option and specify the log mark name. This brings the destination environment online. For more information, see Viewing Restore History.

If there are multiple servers in the destination environment, all servers must be restored to the same backup set. You must view the restore history on each server and make sure that the most recent log backup set restored is the same on all servers. If it is not, you must manually run the restore job on each server that needs the most recent log backup set restored. After all of the servers are on the same backup set, the final set can be manually restored.

Back to Top

Files Added or Changed by SP1 Log Shipping

When you install BizTalk Server 2004 SP1, the Log Shipping feature is enabled. There are also a number of files that are changed on the source and destination system.

Changes to the Source System

As a result of installing BizTalk Server 2004 SP1, the source system is changed in several areas to support the log shipping process and to provide easier administration of the Backup BizTalk Server job. The changes are as follows.

The adm_BackupHistory table is modified

The adm_BackupHistory table is the central history point for the log shipping process for the source system. All backup work performed is recorded to this table. All destination servers read from this table to receive the information needed to perform their restore work.

The Clear Backup History step is added to the Backup BizTalk Server job

This new step in the Backup BizTalk Server job deletes records from the adm_BackupHistory table. Set the @DaysToKeep value to the number of days to keep history. The default value is 14 days. Records older than this value will be deleted.

The Backup BizTalk Server job automatically produces a full backup after a backup failure

The Backup BizTalk Server job logic has been modified to automatically detect cases of backup failures. You can configure the job to automatically create a full database backup set the next time it runs. This begins a new log restore chain.

Note    In some cases, such as a Microsoft® Windows® failure to write data to the backup file, it may not be recognized as a failure by the backup process because SQL Server sees the backup as having succeeded. In this case, the restore process fails due to corruption in the backup file and indicates that the log chain is broken and that a full database backup is needed.

This functionality is not automatically enabled to avoid overwriting existing settings for the BackupFull step.

To enable full backup after a backup failure:

  1. Open SQL Server Enterprise Manager for the server that holds the BizTalk Server Configuration database (BizTalkMgmtDb).
  2. In Enterprise Manager, expand Management, expand SQL Server Agent, expand Jobs, right-click the Backup BizTalk Server Job and open the Properties dialog box.
  3. On the Steps tab, select the BackupFull step and click the Edit button.
  4. In the Command text box add the following parameter to the end of the parameter list in the call to the sp_BackupAllFull stored procedure: , 1

    The text in the Command window should now look as follows:

    EXEC [dbo].[sp_BackupAllFull_Schedule]    'h' /* Frequency */,
                    'BTS' /* Name */, 
                   '\\BackupShare' /* location of backup files */, 
                   1 /* 1 to force full backups after backup failures*/
Note   To disable this feature, set the parameter to 0 or remove the parameter completely.
Important   In some cases it is necessary to force the source system to produce a full backup immediately. This might be necessary in the following situations.

Support for a Larger Number of System Databases

The Backup BizTalk Server logic has been modified to support up to 12 MessageBox databases and up to 12 databases (12 total records) in the adm_OtherBackupDatabases table.

Changes to the Destination System

The destination system is the server or set of servers that restore the backup files produced by a source or set of source systems. When Log Shipping is enabled, each destination environment is comprised of the following pieces:

SQL Server Agent Jobs

Tables

Stored Procedures

Back to Top

Viewing restore history

To determine the last successful backup set restored, review the contents of the Master.dbo.bts_LogShippingHistory table. This table is populated by the "get backup history" job and updated by the restore job. When a backup is successfully restored, the Restored column is set to 1 and the RestoredDateTime is set to the current date and time.

When all of the databases being restored to the server from a particular backup set have been successfully restored, that backup set ID is written to the Master.dbo.bts_LogShippingLastRestoreSet table.

Gaps in the restore process

When reviewing records in the bts_LogShippingHistory table, you may find gaps in the sets restored. This can occur for several reasons. However, you can still recover the stability of your destination system, even when gaps have occurred. A gap must be followed by a restore of a full backup set to repair the destination environment. If a gap is not followed by a full backup set restore, the destination environment is not stable. For more information, see Troubleshooting.

Note   Full backups are only restored to initially create the database and to repair problems in the log history backup chain. In most cases full backup sets are not restored, as they do not participate in the log backup chain.
Back to Top

Fail-over to warm backup

If the source system fails, you can recover by pointing to the destination server so that the destination server becomes the source.

Before you experience a failure, these items must be completed:

  1. Create a set of destination SQL Servers that matches one to one the source SQL Servers.
  2. Back up MSDB on each Source SQL Server anytime you do something that modifies SQL Agent jobs.
  3. Regularly back up all databases that are not part of Log Shipping, including the BAM and Analysis databases.

To recover from a source system failure using the destination backup files

  1. Complete all pre-failure steps as outlined above.
  2. Unplug source SQL Server(s).
  3. Wait for all restore jobs to complete on destination SQL Server(s).
  4. Disable Restore jobs on each destination SQL Server.
  5. Restore all databases with STOPATMARK.
  6. Remove the links to the source SQL Server(s) from the destination SQL Server(s).
  7. Remove the source SQL Server(s) computer account(s) from the domain(s).
  8. Rename the destination SQL Server(s) to match the name of the source SQL Server(s) they replace.
  9. Run sp_RemoveServer 'destinationservername' and sp_AddServer 'sourceservername' on each destination SQL Server.
  10. Restore all databases that are not part of LogShipping on the appropriate Destination SQL Server.
  11. Stop SQL Agent on each destination SQL Server.
  12. Restore MSDB on each destination SQL Server.
  13. Remove each destination SQL Server from its domain.
  14. Reboot each destination SQL Server.
  15. Rejoin each SQL Server to its domain.
  16. Reboot each SQL Server.
  17. Update any DNS entries to point to your new SQL Server(s).
  18. Reboot the Enterprise Single Sign-On (SSO) Master Secret Server (if it is part of the fail-over).
  19. Reboot all BizTalk Servers.
  20. Build a new set of destination SQL Servers.
  21. Bring the destination system on line.

Drop and restore from warm backup

If the source system becomes unreliable, you can restore the databases from the destination to the source.

To restore the databases from the destination to the source.

  1. Disable all backup jobs on Source SQL Server(s).
  2. Wait for all restore jobs to complete on Destination SQL Server(s).
  3. Disable all restore jobs on Destination SQL Server(s).
  4. Restore all databases with STOPATMARK on Destination SQL Server(s).
  5. Stop all BizTalk Services on all BizTalk Servers.
  6. Drop all BizTalk-related databases on Source SQL Server(s).
  7. Backup (full) all databases on Destination SQL Server(s).
  8. Restore (full) all BizTalk Server databases backed up in step 6 to Source Server(s).
  9. Reboot all BizTalk Servers.
  10. Drop all BizTalk Server-related databases on Destination SQL Server(s).
  11. Enable backup jobs on the Source SQL Server(s).
  12. Enable restore jobs on the Destination SQL Server(s).
  13. Reboot the SSO Master Secret Server (if you just restored that database).
  14. Reboot all BizTalk Servers.
  15. Bring the destination system on line.
Back to Top

Troubleshooting

The following information explains some issues common in Log Shipping.

New transaction cannot enlist in the specified transaction coordinator

This error may occur when Microsoft Distributed Transaction Coordinator (MSDTC) is disabled for network transactions when Microsoft Windows XP Service Pack 2 is running on the source system.

To resolve this issue you must enable MSDTC. See Microsoft Knowledge Base article 873160 at http://support.microsoft.com/?kbid=873160 for more information.

Partial backup sets

You may encounter problems when backing up the databases on the source system that result in a partial backup set. When this occurs, the Master.dbo.bts_LogShippingHistory table will contain a 0 in the SetComplete column for all records in the set.

These sets cannot be restored. As a result the log backup set chain is broken. You must ignore this set, as well as all log backup sets after it, up to the next full backup set. The restore job will automatically look for the next valid full backup set. If it does not find one, it fails. If it does find one, it will restore that set in order to repair the destination environment.

In most cases the source system will detect that a partial backup set has occurred and will automatically produce a full backup set the next time it runs if it is configured to do so. For more information, see" Automatically Producing a Full Backup after a Backup Failure" in the topic Changes to the Source System.

Note   The most common cause of this problem is running out of disk space where the files are stored.

Corrupt backup files

A backup file may become corrupt, damaged or missing. If this occurs, at least one file cannot be restored. The restore job on the system that suffered the failure searches for the next valid full backup set. In most cases it will be necessary to force a full backup on the source system. If no such set exists, the restore job fails and each subsequent run also fails until a valid full backup set arrives. If a set does exist, it is used to repair the environment.

Note   Due to the manner in which SQL Server writes backup data to a file, it is possible that SQL Server will report successful completion even if the backup failed during the actual writing of the data. This scenario primarily occurs when the disk being written to is not local to the machine and a network failure or interruption occurs. As a general precaution, if a network failure occurs while the backup job is running, you should force a full backup after the problem is resolved.

Adding a new database to the source system

If you are adding a new database to the source system, use the following steps to modify the Log Shipping system to include the new database:

To add a new database to the source system

  1. Disable the Log Shipping destination jobs on all destination servers.
  2. Disable the Backup BizTalk Server job on the source server.
  3. Add the new database.
  4. Force a full backup on the source system and manually run the Backup BizTalk Server job.

    Check that the new database has been backed up.

  5. Clean the destination server(s).
  6. Add a record for the new database to the Master.dbo.bts_LogShippingDatabases table on the destination server.
  7. Enable the jobs that were disabled in steps 1 and 2.
Note   The restore job will see that the databases do not exist and will create all of them using the most recent full backup set, which is the set created by step 4.

Moving a database to a new server

When you restore a database on an alternate server you get the local users but not the accompanying login. When a log is restored to a different server, you can get "orphaned" logins - that is, the login does not match its database user. SQL Log Shipping requires you to manage your logins separately from your Log Shipping process. For more information, see "HOW TO: Transfer Logins and Passwords Between Instances of SQL Server" in the Microsoft Knowledge Base at http://support.microsoft.com/default.aspx?kbid=246133.

Distributed system problems

In a distributed destination system the restore jobs are not aware of errors or problems on the other machines. For example, machine A is restoring the BizTalkMgmt database and the BizTalkDTA database, and machine B is restoring the BizTalkMsgBox database. Both machines successfully restore backup sets 1 through 25. Set 26 however has a corrupted log backup file of the BizTalkMsgBox database. Machine A restores its databases correctly. but machine B fails to restore the corrupted file.

In this situation, you must force a full backup on the source system. Continuing the example above, assume that the problem was diagnosed and a full backup was created for set 35. Machine A then restores sets 26 to 34, because it is not aware of the problem on Machine B. Machine B will fail until it sees full backup set 35 and subsequent log backup set 36 (remember that there must always be one subsequent complete log backup for a set to be restored). When sets 35 and 36 arrive on machine B, it will repair itself using 35. After the repair is complete, machine A and B will be in sync.

Forcing a full backup

If a restore job is failing and cannot repair itself because it does not have a full backup set, or if the destination environment has been cleaned it will be necessary to force the source system to produce a full backup. To force a full backup, run the stored procedure sp_ForceFullBackup. This procedure is located in the BizTalk Configuration database on the source system. The procedure flags the backup process to produce a full database backup for all databases the next time the job runs. You can also run it manually to immediately create a full backup set.

Cleaning the destination environment

If the restore job encounters error conditions that cannot be resolved, clean the destination environment so that it can start from an empty environment. You clean the environment by running the stored procedure sp_LogShippingClean. This procedure drops all databases and deletes the last restored set data for the specified source.

Before you run this procedure, you should disable the restore job (the get backup history job may continue running). After you run this procedure, the next time the restore job runs it will find the most recent full backup set with a valid subsequent log backup set. If this set has already been restored, it clears the Restored column for the set and all subsequent sets. and then proceeds with restoring the set.

Note   Because the job looks for the most recent full backup set after the environment has been cleaned, you should force a full backup on the source system after running this procedure but before running the restore job.
Note   The sp_LogShippingClean procedure must be repeated on all servers that are restoring databases for a given source system in order to keep the different servers in synch with each other in terms of which sets have been applied.

Resolving login issues after failing over to the warm backup

Depending on how the source system was configured during deployment, you may have to resolve "orphaned" users. An orphaned database user is a user who does not have a corresponding login. You must create corresponding logins for these users before the system can be brought online. You can create these logins at any point, but it is recommended that you create them when BizTalk Server 2004 Log Shipping is configured.

The logins that you create should correspond to the Windows accounts and groups that were used when BizTalk Server was configured on the source system and to any logins that were manually created and used in any BizTalk Server-created role. If these logins correspond to local Windows accounts or groups, the accounts and groups must first be created before the login can be added. If the computer name for the SQL Server is not changed, then you must resolve the users associated with the logins for the local accounts and groups. For more information, see "Establishing Secure Group Accounts" in BizTalk Server 2004 Help.

Note   Knowledge Base article 246133 provides two different methods for moving logins between servers. The method for SQL Server 2000 does not work for BizTalk Server 2004 Log Shipping, because the databases remain in a loading state at all times until they are manually recovered to a log mark.
You can use the method for Microsoft® SQL Server™ 7.0 to create a script that will add the necessary logins to the destination server. This process creates the login script when you first enable BizTalk Server 2004 Log Shipping. When logins are added or removed, you can re-run the script. For more information, see "HOW TO: Transfer Logins and Passwords Between Instances of SQL Server" in the Microsoft Knowledge Base at http://support.microsoft.com/default.aspx?kbid=246133.
Note   Knowledge Base article 240872 provides a method for resolving security identification numbers (SIDs) and computer name conflicts when local Windows users/groups are used. For more information, see "HOW TO: Resolve Permission Issues When You Move a Database Between Servers That Are Running SQL Server" in the Microsoft Knowledge Base at http://support.microsoft.com/default.aspx?kbid=240872.
Back to Top

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 2004 Microsoft Corporation. All rights reserved.

Microsoft, MS-DOS, Windows, Windows NT, Windows Server, and BizTalk are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.