Freigeben über


Using SQL Log Shipping with TFS

This is a refresh of an original post by Suhid Hasbe and updated for TFS 2008.

There are several options for disaster recover within TFS.  In this post we will focu son SQL Log Shipping.  Other options include Backup/Restore and SQL Clustering (mirroring).

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 example if you want to have Primary server in the 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.

Terminology: Primary Server – Main TFS Data Tier, Secondary Server – Backup Data tier Server Before you begin you should have installed SQL Server 2005 or SQL 2008 on the secondary server. Following are the steps to setup Log Shipping for TFS

Configure Log shipping

  1. Connect to the primary server using SQL Server Management Studio
  2. Repeat steps 3-8 for all the TFS Databases(list provided below)
  3. Right Click on each database and select properties
  4. On Properties dialog select Transaction Log Shipping option
  5. Select "Enable this as a primary database in a log shipping configuration"
  6. Click on "Backup Settings" button, this should startup "Transaction Log Backup Settings"
    1. Enter the Network and local paths to the backup directory
    2. Enter reasonable time for delete and alert settings
    3. 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"
    4. Click "OK" to get back to Database properties dialog.
  7. Next Click on "Add" to add a secondary server. This will open a Secondary database settings dialog
    1. Click on "Connect" button and enter connection information to connect to secondary server
    2. 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)".
    3. Click "Restore options" button to select the location of data files and transaction log files on secondary server.
    4. Select the "Copy Files" tab and enter the destination folder for the copied files on secondary server.
    5. Click "OK" to get back to database properties dialog
  8. 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.1) for all databases at same time. e.g. all of them can run after every 1 hour starting 7:00PM. 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.

  1. On the Team Foundation application-tier server, prepare and stop the services.(Detailed steps)
  2. 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

  1. 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 location for TFS and change to the \Tools sub-directory.
  • Run the TFSAdminUtil tool with the RenameDT option to map the Application Tier to Secondary Server

TFSAdminUtil RenameDT <SecondaryServer>

  1. On the Team Foundation application-tier server, reconfigure Report Server .(Detailed steps)
  2. On the Team Foundation application-tier server, reconfigure SharePoint. (Detailed steps)
  3. On the Team Foundation application-tier server, restart the services. (Detailed steps)
  4. Update the work item cache. (Detailed steps)

 

TFS Databases: ReportServer, ReportServerTempDB, STS_Config_TFS, STS_Content_TFS, TfsBuild, TfsIntegration, TfsVersionControl, TfsWarehouse, TfsWorkItemTracking, TfsWorkItemTrackingAttachments, TfsActivityLogging

Comments

  • Anonymous
    August 17, 2011
    Does TFS 2010 support Log shipping on SQL server 2008?