Monday, March 2, 2009

Recover a document from the Sharepoint Server 2007


This is an intresting article to know How to Recover a document from MOss2007
In the scenario whereby a document has been deleted from both levels of the
SharePoint recycle bin, you may have a request to recover it. Assuming you have
a SQL database backup of the content database which hosted the document, you can
get it back with minimal effort by following the steps below.

1) SQL Query to get the Document Content in binary format from MOss2007 Content Database.


SELECT AllDocStreams.Id, AllDocStreams.[Content], AllDocStreams.Size, AllDocs.Version, AllDocs.TimeLastModified, AllDocs.CheckoutUserId,
AllDocs.CheckoutDate, AllDocs.IsCurrentVersion, AllDocs.DirName, AllDocs.LeafName, AllDocs.[Level]


FROM AllDocs INNER JOIN


AllDocStreams ON AllDocStreams.Id = AllDocs.Id AND AllDocs.[Level] = AllDocStreams.[Level]
WHERE (AllDocs.DirName = 'sites/Test/Shared Documents') AND (AllDocs.LeafName = 'MOss2007-Details.docx')


If you get multiple records returned, you will want to use the Version field and the isCurrentVersion and perhaps the TimeLastModified fields to determine which record in the one you want to extract.
2) Extract the Document using TextCopy(Utility available in SQL2000 and it will used in this way )

textcopy /s @server /u @user /P @password /d “@database" /t docs /c content /F c:\temp\filename /O /Z /W "where ID= ‘@IdofRecord’ and Level=’@levelofrecord’

Variables
@database = content database
@server = name of SQL Server machine to use
@leafname = filename
@dirname = directory name of file
@IdofRecord = Id of the content record to extract
@levelofrecord = level of content record to extract

Other then nthis a custom utility has been written to read this binary data and save it in to the specified format.





No comments: