So You Were Forced to Use the dreaded TFS Collection /Recover Command, Now What?

by Angela October 11 2012 08:23

Since we have used Recover on a production database and lived to tell the tale I thought I would share our experiences. If you read this post you will know that one of my client’s got themselves into a world of hurt where we needed to restore a nightly backup that was not detached.  I know, I know, detached backups, or using the TFS Database Backup Power Tool to backup and Restore, are the way to go.  Well, now THEY know that too Winking smile  Nonetheless, sometimes you may find yourself needing to recover a TFS Team Project Collection (TPC) database, and if you’ve read the MSDN documentation you’ll know this is not an ideal situation. The Recover command is very lossy, BUT you get your data back. And in our case it was worth the risk.

So here is the backstory…  Someone deleted a Test Plan with a month’s worth of data in it, and if you know MTM you know there is no “undelete”. Restoring a backup was our only hope. BUT our nightly backups are SQL backups of the entire SQL Server instance, so undetached (we are addressing this NOW). The TFS Backup Power Tool does not detach the databases before backing them up, but it automates something a bit more complicated to allow you to restore single collections from a full backup. Plucking one TPC out of what we had, and attaching it to the TFS instance was just not an option.  You cannot attach a collection that thinks it is already attached.  Trust me, I know. And unfortunately we did not have extra hardware sitting around to allow us to restore the entire thing to a different instance to detach it properly.  So here is what we did:

  1. Restore the backed up TPC from the nightly backup into our dev TFS environment
  2. Used the TFSConfig /Recover command, followed by TFSConfig /Attach to get it attached in dev
  3. Used the TFSConfig /Recover command to get the TPC into the proper state
  4. Detach the hosed TPC from production
  5. Restore that detached version of the TPC to production
  6. Attach the backup to production (we actually hit an interesting bug in TFS 2010 at this point, so the attach was quite harrowing and involved an emergency hotfix to our TFS sprocs, I may blog about later.)

Now, I would love to say everything was perfect but the recover command did blow away some things that we had to get back into place before people could use the TPC again.  What we lost:

  1. All the security setting ever!
    • Collection level groups and permissions
    • Team Project (TP) level groups and permissions in every TP in the TPC
    • Permissions around Areas and Iterations in every TP in the TPC
    • Permissions around Source Control in every TP in the TPC
  2. SharePoint settings  (in every TP in the TPC). Settings on the SharePoint server themselves will be fine of course but you will probably see a “TF262600: This SharePoint site was created using a site definition…” error when you try to open the portal site that was once attached to those TPs. You will need to fix this in 2 places.
    • Go to TFS Admin Console, select the TPC you just restored and make sure the SharePoint Site settings for the TPC are correct. It will probably be set to “not configured” now.
    • Open team explorer (as an Admin user), and for each TP go to “Team Project Settings | Portal Settings” and verify everything there is correct. Ours were just plain gone so we had to enable the team project portal and reconfigure the URL.
  3. SSRS Settings – this will probably be fine if you restored the database as-is but we also renamed it as part of the restore, and so had to update the Default Folder Location through the Admin Console for the TPC in order for this to work again.

So word to the wise, make sure you understand what the settings above are for all of the TPs in your TPC BEFORE you perform a Recover command because chances are you will have to manually set them all back up. And please, PLEASE backup your TFS databases properly.

Tags:

ALM | Application Lifecycle Management | MSDN | MTM | Microsoft Test Manager | Microsoft Test Professional | TFS | TFS 2010 | Team Foundation Server | VS 2010 | Visual Studio | TFS Administration

Comments (2) -

Patrick Cahill
Patrick Cahill United States
11/6/2012 7:14:23 AM #

Hello,

We have almost an identical situation as the one you spoke of, except our user deleted a test plan with over a year of data. So we have our nightly backup of the TPC from before the delete. And like your user's situation, our backups are not detached. So we want to just stand up the TPC backup on another dev server, while still having the current TPC running in our production environment. However, in your steps above (#4) you say to "Detach the hosed TPC from production". Nothing is wrong with our production TPC. I just want an older version of it to live on a different TFS instance. Is this step necessary? If I restore the db to another instance, will that TPC collection interfere with the production version since they are on the same network? I'm ok with all the data loss you spoke of for the restored db on the dev server, but there is no way I can afford any of that on production.

Thank you for your time,
Patrick

zephans
zephans United States
11/8/2012 10:23:18 AM #

@Angela: I've been fortunate enough to avoid this mess (so far) but it is an outstanding cautionary tale. Thank for takint the time to blog about it.

@Patrick: I agree with your approach of attaching the repaired TPC as a separate instance, but there are trade-offs that depend on how tightly integrated your test plan is with your ongoing work item and source code changes. You can attach a backup as a separate TPC (though you must very clearly rename it to ensure everyone knows which one to use for checkins and work items!!!). The Test team can continue using the backup-restored TPC instance AS AN ARCHIVED REFERENCE for as long as they need for this TPC (perhaps finishing the test pass before rebuilding in the live PROD TPC. HOWEVER the test team can't do several things:
* Connect to builds triggered by source code changes or build quality changes
* Create bugs (which should only be in the live TPC)
* Update test case steps or other test case management (since archive TPC won't update live TPC)
* Connect or relate to any new work items created in the live TPC

Our team has about 20 people and we don't have tight build-test automation integration enabled yet, so just using the archive would be preferred. In fact we rarely have a Test Plan that exceeds 3 weeks and they are not terribly complex. Larger teams with huge waterfall test pass tied to builds may need to do the full restore and deal with restoring security groups (which is a deal breaker for me personally).

Enjoy! -Zephan

omcintosh1974
omcintosh1974 United Kingdom
3/20/2013 10:08:25 AM #

get hold of the newest voucher codes from the protein works
protein works coupon codes

Shaka
Shaka United States
3/22/2013 10:06:26 PM #

Great blog. Interested in guest posting at my blog?

Shaka
kindlefiresupport.net

brooks25
brooks25 United States
4/5/2013 4:00:07 PM #

Hi there}Informative article, and just what I was looking for.

frazier1977
frazier1977 United States
4/8/2013 3:42:58 AM #

What's up.Hello to Each. I am seriously thankful I discovered your blog. I am wanting to get caught up. I got designated this for future useful resource and anticipate to be involved in future conversations.  Cheers.

ethornton1965
ethornton1965 United States
4/28/2013 8:49:13 AM #

It's appropriate time to make some plans for the future and it's time to be happy. I've read this post and if I could I wish to suggest you some interesting things or advice. Maybe you can write next articles referring to this article. I wish to read even more things about it!

jeffery8
jeffery8 France
5/12/2013 10:10:17 AM #

J'ai fini par decouvrir qu'il y a une technique exceptionnelle pour apprendre a nourrir son corps et maigrir naturellement.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading