I had my working folder set to a RAM drive. During the night there was an extended power outage, the UPS ran out and my machine went down. Thankfully I shelved my changes before I went home and that shelveset is visible in Team Explorer. The changeset includes the project file and some new files which have not yet been added to source control.
I'm attempting to recover the affected files but am getting errors:
Attempting to view the shelved files gives TF10187
(or a general, unnumbered) The system cannot find the file specified
even though I can see them in the Pending Changes
list.
Attempting to unshelve the set in its entirety gives errors relating to incompatible changes
which I can't resolve.
I'm guessing TFS cached the shelveset locally on the RAM disc which has since reinitialised itself and therefore lost the cache, but I'm hoping I'm wrong.
Can anyone assist?
I had someone come to me and ask the same question yesterday, fortunately they had a backup of the TFS Project database (tfs_) so we restored that to another database and I poked around and figured it out (so, if you have a backup then yes, you can recover all the files).
First of all a little info on the tables in the database.
A Shelveset can be identified by querying the tbl_Workspace table and looking for all records with Type=1 (Shelveset), you can of course also filter by name with the WorkspaceName column.
The other tables of interest are:
tbl_PendingChanges (which references the WorkspaceId from tbl_Workspace) - which files are part of the ShelveSet
tbl_VersionedItem (linked via ItemId column to tbl_PendingChanges) - parent path and name of files
tbl_Content (linked via FileId to PendingChanges) - this is where your file content is stored in as compressed (gzip) data
Now for the solution; the following query can show you your files:
SELECT c.[CreationDate], c.[Content], vi.[ChildItem], vi.ParentPath
FROM [dbo].[tbl_Content] c
INNER JOIN [dbo].[tbl_PendingChange] pc ON pc.FileId = c.FileId
INNER JOIN [dbo].[tbl_Workspace] w ON w.WorkspaceId = pc.WorkspaceId
INNER JOIN [dbo].[tbl_VersionedItem] vi ON vi.ItemId = pc.ItemId
WHERE w.WorkspaceName = '<YOUR SHELVESET NAME>'
With that I wrote some code to get the data back from SQL and then decompress the content with the GZipStream class and save the files off to disk.
A week of work was back in an hour or so.
This was done with TFS 2010.
Hope this helps!