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.


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:


This is for an attached database:


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


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: ,,

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

    1. Awais

      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

  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?

      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?

    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.

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s