Search code examples
tfsazure-devopstfs-2015

Restoring tfs from backup - problem with attaching collection


I have backups of TFS created by TFS' 2015 scheluded backups and I'm trying to restore them on different server, but for some reason I cannot even attach collection (not even talking about Tfs_Configuration yet). I managed to restore backups via TFS Console -> Scheluded Backups -> Restore

but I cannot attach it

TfsConfig registerDB /sqlInstance:SQL\NEW_TFS /databaseName:Tfs_Collection1

The following exception was caught while trying to validate the database:
TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator.

What's the reason behind this?

I tried this https://stackoverflow.com/a/10853481/10522960 to solve that, but it doesn't help at all

Also

First, please make sure you are a member of the Team Foundation Administrators security group and a member of the sysadmin security group for any SQL Server databases that Team Foundation Server uses.

There's no such group (Computer Management -> Local Users and Groups -> Groups), shouldn't it be created by tfs?

TfsConfig offlineDetach /configurationDB:SQL\NEW_TFS;Tfs_Configuration /collectionDB:SQL\NEW_TFS;Tfs_Collection1

The database 'SQL\NEW_TFS;Tfs_Collection1' is hosting Team Project Collection with ID 'da9b771c-a149-62d1-a7b0-e
1ad79977102', however this collection is not registered in the specified configuration database.

I've been trying to change Application Id inside

C:\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\web.CONFIG 

to da9b771c-a149-62d1-a7b0-e1ad79977102 but it doesn't help at all

Does anyone has an idea what's going on? Thanks!


Solution

  • If you want to restore the standard backups without detaching a collection you need to restore the configuration database first. You will also need to update the TFS GUID otherwise it will identify as the same TFS server as the original and weird stuff will happen in visual studio.

    When you detach a collection all of the collection specific configuration is copied from the configuration database in to the collection database. This process makes the collection portable, note that this will also take the collection offline. You can then back up the collection database and restore it to a new TFS server with a "clean" configuration database. Once the backup is restored you will be able to attach the collection.

    Attaching the collection will then copy all of the collection specific configuration in to the new configuration database