Originally, we installed TFS in an SQL Express database, to test it out. Please note that we only wanted Source Control, Workitem Tracking and Build services, so we went for the Basic Wizard setup. Then we decided to move TFS to an MS SQL 2008 server, so we could plan our maintenance and automate all backups.

The process of moving Team Foundation Server (TFS) to another database is rather simple, but it comes with its own caveats. Here is how to do that in several easy steps:

 

1. Detach the available collections

  • start the TFS Administration Console
  • expand the Application Tier of the computer where TFS is installed and select the Team Project Collections
  • select each collection and, using the General tab below, write down its database name via the Edit Settings link (you can see the SQL Server Instance name there too, if you have forgotten it)
  • then use the Detach Collection link to detach it
  • finally, close the TFS Administration Console

2. Copy the databases from the original SQL instance to the new one:

  • start the SQL Server Management Studio and connect to the original database
  • create backups all the available collection databases to a folder on your hard drive
  • make sure you back up the Tfs_Configuration database too
  • then connect to the new database and restore all of the backups to the new instance’s DATA folder (or to a folder of your choice)

3. Uninstall the Application Tier

  • run this command:

“C:Program FilesMicrosoft Team Foundation Server 2010Toolstfsconfig” setup /uninstall:all

  • either via the Run… dialog, or in a command prompt

 

4. Install the Application Tier anew, with the new connection string

  • start the TFS Administration Console
  • select the Team Project Collections item under the Application Tier of the computer where TFS is installed, if it is not already selected
  • click the “Configure Installed Features” link you will see
  • select the “Application-Tier Only”, and click the “Start Wizard” button in the bottom right corner
  • specify the new connection string and TFS should automatically find its configuration database, which you have copied over in 2.

 

5. Attach all collections

  • select the Team Project Collections and use the “Attach Collection” link to attach all collections from the new SQL instance

Voila, you are done. Now start Visual Studio and test your TFS. You can optionally stop the old SQL instance before that, to be extra sure the migration is complete.

start the SQL Server Management Studio and connect to the database