Database.ca SQL Server Blog

My Blog

Monday, December 16 2013

Keywords: TFS 2010, Team Foundation Server 2010, Disaster Recovery, DR, Disaster Preparedness

Quick & Simple Team Foundation Server 2010 Disaster Recovery

"I can't connect to TFS this morning" I was told as I walked in a few days ago. Oh, I had heard this type of statement many times before...they had all been benign...but on this particular day it ended up actually being a production TFS 2010 server total disaster.
 
Be prepared for your TFS 2010 disaster recovery in four steps:
 
*) Get the right information...I have a separate article on how to master TFS.
 
*) Understand the database
deployment topology used in TFS 2010.
 
*) Get the right tool to make your admin-life easier: Team Foundation Server 2010 Power Tools comes with "Backups" tool that can schedule backups for all your TFS databases, and does so in a fashion that ensures a consistent snapshot with all of the other databases.
 
*) Test Practice TFS DR...one thing you should perform at least a couple of times per year would be to actually simulate a DR and restore the entire TFS data (source control, work items, reports and SharePoint) on a new machine.

 

Disaster preparedness:
 
1) Create a database maintenance plan using Team Foundation Server 2010 Power Tools' Backups app. You would need full database backups, hopefully once a day if the size of your databases allows. You need a backup of all your TFS databases, as well as your Reporting Services databases...as well as SharePoint etc. Reporting Services related databases could be backed up as part of a regular SQL Server Maintenance Plan and it is not the end of the world if they are not in a 100% consistent transactional state with the rest of TFS databases. Read here to learn how to use TFS 2010 Power Tools to backup and restore TFS databases.
 
2) Always using TFS 2010 Power Tools...Have log backups one to multiple times per day. The interval between them would solely depend on your requirements. Banks might do it every 10 minutes. Airports every 20 minutes. Some companies once per hour, some do it twice a day: 9 a.m. and 2 pm etc…
 
3) Make sure the full database backup files as well as the log backup files are all copied to either an ultra-fast backup device or a network drive or both.
 
4) Take a good note of Collation of your TFS databases!
 
5) With the help of Reporting Services Configuration Manager, backup your server's key and keep its password written somewhere safe. You will need this password...make sure it will be handy in time of disaster!
 
6) Using TFS Power Tools export all the custom work item process templates you might have and save them into the TFS backup folder that gets backed up every day.
 
7) Have installation media always handy for:

  • Windows Server
  • Windows Server service pack
  • TFS
  • TFS service pack and patches
  • TFS server-side plugins if any
  • Any other apps you need to install on the TFS app server
  • SQL Server
  • SQL Server service pack

 

TFS 2010, Team Foundation Server 2010, Disaster Recovery, DR, Disaster Preparedness

Disaster Recovery, simplified version:

 

1) Stop all TFS services, if any still running.
 
2) If you need to re-install SQL Server: Make 100% sure you install it with exact same collation as the production databases. Restore databases. Read here to learn how to use TFS 2010 Power Tools to backup and restore TFS databases.

 

3) If you are not re-installing SQL Server: backup databases and the encryption key.
 
4) Install TFS: do Not run the TFS Configuration Tool at the end, not just yet. Install TFS Service pack now.

 

5) Prep your database:
 
Use TFSConfig which is by default locatged in C:\Program Files\Microsoft Team Foundation Server 2010\Tools>.
 
TFSConfig PrepSQL /SQLInstance:ServerName

 

6) Remap your database:
 
TFSConfig RemapDBs /DatabaseName:ServerName;TFS_Configuration /SQLInstances:ServerName,ServerName2 /AnalysisInstance:ServerName2 /AnalysisDatabaseName:DatabaseName
 
7) Change ownership, if you need:
 
TFSConfig Accounts /ResetOwner /SQLInstance:ServerName /DatabaseName:DatabaseName

 

8) Update service accounts:
 
TfsConfig Accounts /add /AccountType:ApplicationTier /account:AccountName /SQLInstance:ServerName /DatabaseName:DatabaseName
 
TfsConfig Accounts /add /AccountType:ReportingDataSource /account:AccountName /SQLInstance:ServerName /DatabaseName:DatabaseName

 

TFS 2010, Team Foundation Server 2010, Disaster Recovery, DR, Disaster Preparedness

9) Run the TFS Config tool, choose the APP ONLY path and select the existing config database when asked.
 
10) Restore Reporting Services databases and restore the key, using the password you had kept aside in the preparedness phase.
 
11) If the database server has changed, then you would need to navigate to your report server portal and modify the connection string of your reports' DSN to point to the new database server. You would also need to use Reporting Services Configuration Manager and make sure all information in it are correct and up to date, especially the service accounts.
 
12) If you were utilizing custom work item process templates, you could always restore them in to a fresh TFS install, by using TFS Power Tools.

 

At this point version control, work items, and reports are up and running and users can already connect to the TFS server in a variety of ways and check-in check-out and read and modify the work items and reports. I did not go into details of how to restore SharePoint databases here…you could look it up yourself and do it peacefully now that the most important parts have already been recovered: all source code, and all work items and reports.

 

Written by Ramin Haghighat