Let’s continue our discussion around Failover options in TFS. We already spoke about Backup/Restore, SQL Mirroring or SQL Clustering. One more option available is SQL Log Shipping. Log Shipping is very close to Mirroring. The only difference is Mirroring is almost real-time synchronization of databases whereas Log shipping is time delayed synchronization. In short you can synchronize the databases every X minutes. This helps when the geographic locations of primary and secondary servers are far apart for e.g. if you want to have Primary server in US and Secondary backup server in Asia. You do not want to do mirroring in this case, as it may slow down the primary server.
Caution: This is not an officially supported configuration. I have tried it and it works fine. Please test this on your test environments before trying it in production.
Terminology: Primary Server – Main TFS Data Tier, Secondary Server – Backup Data tier Server
Before you begin you should have installed SQL Server 2005 on secondary server. Following are the steps to setup Log Shipping for TFS
Configure Log shipping
- Connect to the primary server using SQL Server Management Studio
- Repeat steps 3-8 for all the TFS Databases(list provided below)
- Right Click on each database and select properties
- On Properties dialog select Transaction Log Shipping option
- Select “Enable this as a primary database in a log shipping configuration”
Click on “Backup Settings” button, this should startup “Transaction Log Backup Settings”
- Enter the Network and local paths to the backup directory
- Enter reasonable time for delete and alert settings
- Click on “Schedule button” to open Job Schedule properties dialog. Select the schedule for transferring the transaction logs based on your environment. For example if you have primary server in US and Secondary in Asia you may want to schedule it for every hour. Once you have selected your schedule click “Ok”
- Click “OK” to get back to Database properties dialog.
Next Click on “Add” to add a secondary server. This will open a Secondary database settings dialog
- Click on “Connect” button and enter connection information to connect to secondary server
- Select “Yes, generate a full backup of the primary database and restore it into the secondary database (and create the secondary database if it doesn’t exist)”.
- Click “Restore options” button to select the location of data files and transaction log files on secondary server.
- Select the “Copy Files” tab and enter the destination folder for the copied files on secondary server.
- Click “OK” to get back to database properties dialog
- Click on “OK” and the system will automatically setup the secondary database with log shipping setup.
Note: You should configure the transaction log shipping schedule (step 6.c) for all databases at same time. For e.g. all of them can run after every 1 hour starting 7:00PM 01/01/2007. This is crucial to keep the databases in sync.
Failover to the secondary Database
Important: To failover to the secondary server we have to failover all the databases at the same time.
- On the Team Foundation application-tier server, prepare and stop the services.(Detailed steps)
- On the new Team Foundation data-tier server
- Connect to the secondary server using SQL Server Management Studio.
Run following TSQL Query for each TFS database. This will restore all the secondary databases and make them operational
Restore database <TFSDBName> with Recovery
- On the Team Foundation application-tier server, configure the application tier to use the new data tier.
- On the Team Foundation application-tier server, open the Command Prompt window.
At the command prompt, locate the program file directory, and then type:
cd Microsoft Visual Studio 2005 Team Foundation ServerTools
- Run the TFSAdminUtil tool with the RenameDT option to map the Application Tier to Secondary Server
TFSAdminUtil RenameDT <SecondaryServer>
- On the Team Foundation application-tier server, reconfigure Report Server .(Detailed steps)
- On the Team Foundation application-tier server, reconfigure SharePoint. (Detailed steps)
- On the Team Foundation application-tier server, restart the services. (Detailed steps)
- Update the work item cache. (Detailed steps)
TFS Databases: ReportServer, ReportServerTempDB, STS_Config_TFS, STS_Content_TFS, TfsBuild, TfsIntegration, TfsVersionControl, TfsWarehouse, TfsWorkItemTracking, TfsWorkItemTrackingAttachments, TfsActivityLogging
Note: We are working on officially supporting this configuration. I will keep you all updated
Please let me know if you tried using these steps and found them useful.