Wednesday, November 16, 2011

Restore TFS 2010 database backups to a different server

PROBLEM:
You want to restore your TFS 2010 database backups to a different server

SOLUTION:
For this procedure, lets say your old server name is “OldServer” and your target server name is “TargetServer” .
  1. Connect to the target server “TargetServer” that has already TFS2010 installed. To perform the following, you must belong to administrators group (for example, use "tfssetup" account)
  2. If exists old TFS databases in the target server
    • Backup all databases using one of the following options:
      • SQL Server Management Studio regular database backups
      • Team foundation server administration console --> team foundation backups --> create backup plan. Its preferred that you backup locally (to avoid permission problems in network path, example: “\\TargetServer\TFS_backup”)
    • Delete all databases (Example: ReportServer, ReportServerTempDb, Tfs_Configuration, Tfs_DefaultCollection, Tfs_Warehouse, WSS_AdminContent, WSS_Config, WSS_Content, etc.)
  3. Restore the "OldServer" TFS databases backups to the "TargetServer" using one of the following options:
    • SQL Server Management Studio database restore
    • Using team foundation server administration console --> team foundation backups --> restore databases
  4. When the restore in the "TargetServer" completes:
    • Using Sql Server Management Studio --> change Tfs_configuration database extended property “TFS_BACKUP_PLAN_CONTROLLER” from “OldServer” to “TargetServer”
    • Open the Command Prompt (Run as Administrator) and change directory to
      • CD %programfiles%\Microsoft Team Foundation Server 2010\Tools
    • Prepare SQL Server for the new Team Foundation Server
      • TFSConfig PrepSQL /SQLInstance:TargetServer\SQL2008R2
    • Redirect Team Foundation Server to the new databases (RUN THE FOLLOWING COMMAND LINE TWICE !!! this to avoid the following error “The following exception was caught while trying to validate the database: The database provided is not a valid Team Foundation Server Configuration database for the follow reason(s): Unable to find any compatible SQL Analysis Services database within the specified instance.”)
      • TFSConfig RemapDBs /DatabaseName:TargetServer\SQL2008R2;TFS_Configuration /SQLInstances:TargetServer\SQL2008R2 /continue
    • Redirect the application tier to the new location of the restored databases
      • TfsConfig RegisterDB /SQLInstance:TargetServer\SQL2008R2 /DatabaseName:TFS_Configuration 
  5. Update the URL for the Application-Tier Server. You can skip this procedure if you are not changing the name of the server as part of restoring to new hardware
    • Open the administration console for Team Foundation
    • In the navigation bar, click Application Tier, and then click Change URLs. The Change URLs window opens.
    • In Public URL, type the URL for the new application-tier server “TargetServer”, and then click OK
  6. Restart Services That Team Foundation Server Uses 
    • Close team foundation server administration console (if open) 
    • To stop - type the following command: TFSServiceControl quiesce 
    • To start - type the following command: TFSServiceControl unquiesce 
  7. The backup plan that copied from the "OldServer" should be disable: using team foundation server administration console --> team foundation backups --> recreate backup plan --> schedules, select “manual backup only” 
  8. If needed, refresh the data caches on client computers, see http://msdn.microsoft.com/en-us/library/cc716728.aspx
  9. This procedure is not handling the database restore of SharePoint and Reporting and Analysis Services, for more details see http://msdn.microsoft.com/en-us/library/ff459215.aspx

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

11 comments: