1/01/2010

SharePoint: Exploring SharePoint CMP Export Files (and a demo application)

 

Nearly two years ago I wrote another blog on this topic and referred to a little application I had written to explore a CMP file that could also extract individual files from the CMP. Shortly after that, and before I could upload the app, the hard disk in my laptop died. I recovered most of the content of the drive, but had thought I had lost my Visual Studio directories. Guess what! I revisited that drive (I never throw things away…) looking for some old pictures and I found the missing app!

 

First go read the original article: Exploring SharePoint CMP Export Files. There you can see what’s in a CMP and how to manually extract the files.

 

To help understand the CMP Manifest file I wrote a small .Net program to list the SPObject elements and a handful of attributes from each one.


image

The first step is to open the CAB file and extract the Manifest.xml file. As I have always been amazed at the features found in the .Net libraries, I figured I would find a CAB extractor library in the Framework. Turns out there was one in the one of the Betas, there is not there now. (There is a Zip library though!) So I ended up using the CAB extractor found in Windows, extrac32.exe. (For details type “extrac32 /? | more” at the command prompt.) So within the app I used System.Diagnostics.Process to run extrac32 to extract the files. The Manifest.xml file is then loaded into an XmlDocument object, parsed into a DataTable and then displayed in a GridView.

The List Content button extracts the manifest.xml file from the CMP file and then extracts some of the descriptive content of the manifest file to display a fair amount of detail in the GridView. The manifest documents EVERYTHING about the site, so I added some checkboxes to filter the display.

  • Files Only – well… only displays manifest entries about files (including ASPX, master pages, and other non-content files)
  • Exclude ASPX – hides ASPX files (in the next update I’ll have it hide all non-content files)
  • Include List Items – I hid list content as a default as most of the interesting stuff is in the XML and is different for each list type. If you check this box then all list items are added to the grid. You can check scroll to the right and click in the XML column to see the full XML description of the list item.

Extract All Files extracts all of the files, then renames them and puts them into a SharePoint-like directory structure. Note that this example has three subsites in the backup.

             image

The extracted files are where you would expect them to be, Shared Documents in this example, and still have their correct Date Modified:

image

 

Extract Selected extracts individual files to any location you pick. To select a file click the “selectors” at the left of each row. To select multiple files use the normal click, shift-click, ctrl-click techniques.

            image

 

Downloads

I will probably most this into CodePlex.com, but for now you can download it from here:

  EXE only:   download  (9k)

  Project zip:  download  (107k)

 

.

6 comments:

Anonymous said...

Brilliant!!!!! Thank you for this great tool. It saves a ,lot of time and pain restoring my sharepoint files!

Frank said...

This is a great app for acquiring content. Any ideas how to overcome the dat change on the exported documents? The date modified changes to March 23 2003 on the documents.

emilbloo said...

Frank, I am also struggling with the .dat change. Did you figure out how to overcome it?

Anonymous said...

I tried your tool today. Almost worked perfectly. I had to add this to the source code to make it work:
case "File":
try
{
row["FileValue"] = fileNode.Attributes.GetNamedItem("FileValue").InnerText;
}
catch { }

home.aspx did not have a filevalue attribute so it excepted with a Not set to an instance of an object.

Als, use the c:\temp folder as it cannot handle long directory structures or the code has to be altered to do use quotes aroung c:\program files\this is my directory"
Other than that it work nice to recover the file I needed

Anonymous said...

THANK YOU. I was able to recover the file I needed.

Charles said...

I've re-created a subset of this programs functionality in PowerShell: https://github.com/crossan007/PowerShell-Modules

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.