Migrating a TFS project collection to another server

Occasionally you may want to move your Team Foundation Server database to another server, because for example:

  • You want to upgrade the underlying hardware or software infrastructure.
  • You want to split the project collection between multiple servers.
  • You want a copy of your live data in your test environment.

The process is fairly simple:

  1. Ensure that the target server has the same or newer SQL Server version than the source environment. It is important, because you cannot restore a SQL backup which was created with a newer SQL Server.
  2. Ensure that you have exactly the same version of TFS in both environments. Not only service packs, but also minor hotfixes matter!
  3. In your source server:
    1. Click Stop Collection in the TFS Admin Console.
    2. Click Detach Collection in the TFS Admin Console.
    3. Start SQL Server Management Studio and create a full backup of the database of the project collection.
  4. Copy the SQL backup to your target SQL Server.
  5. In your target server:
    1. Use SQL Server Management Studio to restore the database backup to a new database.
    2. Use Attach Collection in the TFS Admin Console.
    3. Update the SharePoint and Report Server settings according to your needs.

It may happen that when you try to attach the project collection TFS cannot find the restored database and you receive the following error message:

TF254078: No attachable databases were found on the following instance of SQL Server: MyServer. Verify that both the name of the server and the name of the instance are correct and that the database was properly detached using the detach command in the Team Foundation Administration Console.

tfs-attach-db-not-found

The error message is really correct, so you can check the following:

  • Verify that you can connect to the SQL Server instance and the database in it with the TFS service account.
  • Verify that you have exactly the same TFS version in both environments.
  • Verify that you have not skipped Step 3b and correctly detached the project collection from TFS.

TFS verifies the second and the third criteria by querying the list of databases in the SQL Server and then executing the following query in each of them:

SELECT name, value 
FROM   sys.extended_properties 
WHERE  name LIKE 'TFS_%'

This query returns the custom properties of the databases which start with “TFS_”. You can do the same in your target environment, and you will get something similar for your Configuration database:

tfs-properties-configuration-db

This is for an attached database:

tfs-properties-attached-db

And finally you will get something like this for a correctly detached database:

tfs-properties-detached-db

If you cannot see the TFS_SNAPSHOT_STATE property with the Complete value, than you have a fair good chance that you forgot to detach the project collection in the TFS Admin Console before created the SQL backup.

 

Technorati-címkék: ,,

18 thoughts on “Migrating a TFS project collection to another server

    1. Awais

      HI,
      I forgot to detach the collection before taking DB backup and now I m not able to restore it. please let me know the procedure to restore the Collection thru the sql DB backup

      Reply
  1. jamesitpro

    I have installed the exact version of TFS on the new server and verified using your query. It is still throwing the same error though when I try to attach the collection using the TFS console?

    Reply
      1. Alex

        Thanks for sharing. Information about step 3 with sql and result for detached collection are very useful! Thanks again.

  2. Vinay Sandela

    In our Organization, we are using TFS 2017.1 in Windows Server 2008 with SQL 2014.
    We are planning to upgrade to TFS 2018, where minimum requirement of OS is Windows Server 2012.
    So, We have got our servers ready with Windows Server 2016 and SQL 2016 installed.

    So, Do we need to move our 2017.1 instances first to new Server, then proceed with the Upgrade?

    Reply
    1. György Balássy Post author

      I wrote this post 5 years ago, so it might not be true for more recent versions, but yes, this process preserves the file history, because that old version stores everything in SQL.

      Reply
  3. Pingback: Migrating a TFS project collection to another server | Welcome to My World

Leave a reply to jj Cancel reply