Share via

How to recover .net source code files from the TFS backup file.

eSRC 0 Reputation points
2025-09-04T08:12:26.1666667+00:00

I restored the TFS server using SSMS and trying to connect with the Azure DevOps server hoping to restore the source code of an existing project. But I while trying to attach the collection, the DevOps server is unable to recognize the collection database. I want to restore the .net source code from the tfs backup file.

Azure DevOps

1 answer

Sort by: Most helpful
  1. Anurag Rohikar 3,190 Reputation points Microsoft External Staff Moderator
    2025-09-09T10:34:12.19+00:00

    Hello,
    When restoring a TFS/Azure DevOps Server project collection, simply restoring the database in SQL Server Management Studio (SSMS) is not enough. The TFS/DevOps application tier expects the database to be registered and attached in a very specific way. That’s why your DevOps server cannot recognize the collection database.

    To recover your .NET source code, here are the supported options:

    1. Use the TFS Admin Console to Attach the Collection
    • Open TFS Administration Console on your Azure DevOps/TFS server.

    Navigate to Team Project Collections → Attach Collection.

    Point it to your restored database.

    This process runs validation, upgrades schema if needed, and formally registers the collection.

    If the DB version is older/newer than your server version, you’ll need to install the matching TFS/Azure DevOps Server version before attaching.

    1. If You Only Need Source Code (Not Full TFS)

    If your main goal is just to recover the .NET source files and not the full TFS environment:

    Restore the collection DB in SSMS.

    • You can query the tbl_VersionControl tables in the database (not officially supported, but technically possible) to extract file contents.

    However, this is painful and unsupported.

    Instead, use the official TFS Integration Platform or install a matching version of Azure DevOps Server (on-prem), attach the collection properly, and then use Team Explorer/Visual Studio to get the latest source code.

    1. Important Notes
    • You must restore all related databases (Configuration DB + Collection DB + optionally Warehouse/Analysis if you need reporting).

    TFS collection DBs are not standalone – attaching only one DB will fail.

    Versions must match: if your backup is from TFS 2017, you need TFS 2017 to restore and then upgrade step by step.

    Additional Reference:

    I hope the above information helps, to exactly troubleshoot further please help us with requested information to check and assist you further on this. Thank you!

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.