I wanted to try Windows 8 final on my spare desktop. Trouble was that I had my TFS on that machine (which I use sometimes). So I wanted to move that collection to my other newer desktop. These are the steps that worked:
1. Go to TFS Admin console and detach all collections
2. Go to SQL Server and detach all TFS_ databases
3. Copy the .ldf and .mdf files to the target machine.
1. Make sure TFS Server 2010 is installed
2. On SQL Server Replace the TFS_Configuration and attach other TFS_Collection databases
3. Go to TFS admin console and attach the collections
Problem 1. Target Machine: The collection is in attaching state forever (for more than one day).
The following steps fixed the issue.
1. Check the Application event log for errors; I got the following Warning:
TF30046: The instance information does not match. Team Foundation expected [WrongGUID] but found [CorrectGUID]. Please contact your Team Foundation Server administrator. (type DatabaseInstanceException)
I searched online and found the following solution:
2. Go to Program Files\Microsoft Team Foundation Server 2010\Application Tier\Web Services
3. Backup Web.config
4. Open Web.config and replace the [WrongGuid] in the message above with the [CorrectGuid] in the message.
6. Restart Services: Visual Studio Team Foundation Background Job Agent
7. Collections are now online.
Problem 2: There were no projects when I connected through Visual Studio!
This was baffling and I didn’t find any errors. I tried TfsConfig recover command and TfsConfig repair commands and neither helped.
I did the following query on the Tfs_DefaultCollection database:
SELECT * FROM [Tfs_DefaultCollection].[dbo].[tbl_Project]
It returned 0 rows.
I added a new project from Visual Studio and ran it again. It returned 1 row.
Then I found the issue. I had two copies of Tfs_DefaultCollection files on disk, one of them was 25MB other was 500MB. I detached the 25MB copy and attached the 500MB copy – lo and behold! My projects are back.
Problem 3: Work items are missing
Will look into this later. These are home projects and I don’t care about work items for now.
UPDATE: Work items loaded up after 10-15 mins! Issue closed.