Welcome to TechNet Blogs Sign in | Join | Help

Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

[Part 1 - Part 2 - Part 3 - Part 4 - Part 5 - Part 6]

Introduction 

Today I would like to start an article series on an interesting new feature in WSS 3.0: the Content Deployment and Migration API. A similar API has previously been provided in MCMS 2002 and was also added to WSS after MCMS was integrated in MOSS 2007. This first part will provide an overview about the API itself. In future chapters I will then demonstrate how to utlize this API to enhance your own applications or to get a better granularity than the out of the box tools allow you to do - e.g. how to copy a document library or a list to a different site collection.

WSS and MOSS use this API at various different places:

  • Content Deployment
  • STSADM -o export and import
  • Copy/Move operations in Site Manager
  • Variations
  • MCMS 2002 database migration to MOSS 2007

Actually any time when content needs to be copied or moved to a different location either in the same or in a different site collection.


Feature set of the Content Deployment and Migration API

The Content Deployment and Migration API provides the following features:

  • export an entire site collection
  • export a specific site inside a site collection including or excluding content in subsites
  • export a list or document libraries or even of a folder inside a document library
  • export a single list items or documents from a document library
  • export dependent objects (like images referenced by a page) by following links
  • generate as a compressed export file or in uncompressed format
  • allow export with a define a maximum size for the generated compressed file (multiple export files will be created if required)
  • allow incremental export of items based on a given change token. This will export all items that have been created, changed or deleted after the timestamp in the change token.
  • import the exported content with or without identiy preservation (means items will keep their GUID or not)
  • import the exported content under the same or a differnt parent in the destination database
  • do link fixup during import

For people who have also worked with Microsoft Content Management Server (MCMS) 2002 here is a feature comparison between the site deployment API of CMS 2002 and the content deployment and migration API coming with WSS:

   
MCMS 2002
 
WSS 3.0
incremental deployment  
yes
 
yes
full deployment  
no
 
yes
deployment of a subtree of the site structure  
yes
 
yes
deployment of specific selected items  
no
 
yes
deployment of dependent items  
yes
 
yes
deployment by ignoring the dependencies  
no
 
yes
deployment of child elements of the exported elements  
yes
 
yes
deployment without exporting of child elements  
no
 
yes
import with preservation of the last modified date of the source item  
no
 
yes
import without preservation of the last modified date of the source item  
yes
 
yes
export of image libraries/resource galleries  
no
 
yes
support import at multiple locations in the site hierarchy  
no
 
yes
can be used to migrate 3rd party content  
no
 
yes


Programming Reference

Assembly: Microsoft.SharePoint.dll
Namespace: Microsoft.SharePoint.Deployment

Important Objects:

  • SPExport - controls the Export process
  • SPExportSettings - used to configure the export process
  • SPExportObject - defines which objects need to be exported
  • SPImport - controls the import process
  • SPImportSettings - used to configure the import process

You will find details about these objects in the MSDN:
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.deployment.aspx

Rather than listing all the different properties and methods of these objects (which are already documented on MSDN) I will explain how to use these objects by providing some "real-world" samples in the next chapters:

  • Part 2 - Providing some real world samples on export
  • Part 3 - Providing some real world samples on import
  • Part 4 - Advanced content deployment scenarios
  • Part 5 - Avoiding common problems
Published Thursday, August 30, 2007 6:47 PM by Stefan_Gossner

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# MSDN Blog Postings » SharePoint Content Deployment and the Migration API

Friday, August 31, 2007 12:41 AM by Noticias externas

# SharePoint Content Deployment and the Migration API

Stefan is back! J Stefan is in Redmond this week, and we had a chance to catch up! In fact, I had dinner

Friday, August 31, 2007 5:32 AM by SharePoint, SharePoint and stuff

# Deep Dive in SharePoint Deployment und Migration API

Stefan Goßner taucht in einer vierteiligen Serie in die Tiefen der SharePoint Deployment und Migration

Friday, August 31, 2007 5:41 PM by Stefan Goßner

# Deep Dive into the SharePoint Content Deployment and Migration API - Part 3

[ Part 1 - Part 2 - Part 3 - Part 4 ] Providing some real world samples for import After we managed to

Friday, August 31, 2007 5:41 PM by Stefan Goßner

# Deep Dive into the SharePoint Content Deployment and Migration API - Part 2

[ Part 1 - Part 2 - Part 3 - Part 4 ] Providing some real world samples for export To demonstrate how

Friday, August 31, 2007 9:40 PM by Andrew Connell [MVP MOSS]

# Fantastic, incredibly detailed, content on content deployment by Stefan

Fantastic, incredibly detailed, content on content deployment by Stefan

Friday, August 31, 2007 10:00 PM by Mirrored Blogs

# Fantastic, incredibly detailed, content on content deployment by Stefan

[via Stefan Gossner ] This past week I was in Redmond teaching my WCM401 development class in an open

Sunday, September 02, 2007 2:03 PM by Jorge Dieguez Blog

# Migración de contendidos SharePoint de forma programática

En la última versión de SharePoint se ha incluido un interesante conjunto de herramientas que permite

Monday, September 03, 2007 6:03 AM by Mirrored Blogs

# Content migration API "Deep Dive" by Stefan Goßner

Body: Great series of posts by Stefan on how to use the Content Migration API. Very timely for me as

Tuesday, September 04, 2007 1:03 PM by Microsoft Enterprise Content Management (ECM) Team Blog

# A deep dive into the SharePoint Content Deployment and Migration API

If you haven't seen it already, Stefan Goßner has published a great series on how to develop using the

Thursday, September 06, 2007 2:36 AM by Shared Points...

# Stefan Goßner Deep Dives into SharePoint Content Deployment

Stefan Goßner has published a four article series on how to develop using the Content Deployment and

Tuesday, September 11, 2007 11:02 AM by Joycode@Ab110.com

# SharePoint内容部署与迁移API

今天凌晨加班的时候偶然翻到 Stefan Gossner 的这几篇文章,强烈推荐给大家: Deep Dive into the SharePoint Content Deployment and Migration

Tuesday, September 18, 2007 5:43 PM by David Remillard

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

I'm having difficulty with export/import of a site from one farm to another.  The problem has to do with the Data View Web Parts that are in the site.  Apparently, they persist reference to the GUID of the datasource (list)?  Do you have any guidance for this scenario?  Thanks.

Wednesday, September 19, 2007 3:10 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi David,

is the list the data view web part points to also in the package?

Anyway: I would suggest to open a support call to get investigated if this should work or not.

I personally haven't looked into the details of this till now.

Cheers,

Stefan

Saturday, September 22, 2007 11:11 AM by Mirrored Blogs

# Brilliant and detailed view of content management API

Stefan Goßner has put together a terrific 4-part series on the SharePoint Content and Deployment API

Tuesday, September 25, 2007 5:49 AM by Connecting Systems the Microsoft Way

# MOSS / SharePoint Content Deployment

Great set of articles by Stefan Goßner : Deep Dive Into the SharePoint Content Deployment...

Friday, September 28, 2007 2:38 AM by Connected Systems Chilled Out Blog

# MOSS / SharePoint Content Deployment

MOSS / SharePoint Content Deployment

Sunday, October 14, 2007 7:47 PM by Mirrored Blogs

# Deployment using STSADM export or content migration API

Having focused on deployment using Features for several articles, back in May I wrote an article titled

Monday, October 29, 2007 7:43 AM by Mirrored Blogs

# STSADM export, Content Deployment, Content Migration API, Features/Solutions - deployment options compared

Back in May I wrote a post titled SharePoint deployment options : Features or Content Deployment? , which

Thursday, November 22, 2007 12:40 PM by Jenny

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Can you deploy content from a MOSS environment to a WSS environement?

Thursday, November 22, 2007 3:00 PM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Jenny,

MOSS is on top of WSS. As long as you are only using WSS features in the deployed content it will work. As soon as you are trying to deploy content that is bound to features which are only available in MOSS it will fail.

Cheers,

Stefan

Friday, November 30, 2007 6:04 PM by Microsoft SharePoint Developer Documentation Team Blog

# Content Migration in SharePoint

Around the time work started on a long whitepaper about migrating content files from SharePoint server

Friday, November 30, 2007 6:21 PM by Noticias externas

# Content Migration in SharePoint

Around the time work started on a long whitepaper about migrating content files from SharePoint server

Wednesday, December 12, 2007 10:33 AM by gbelzile

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

FYI... the diagram is truncated on the right.

Wednesday, December 12, 2007 11:07 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Maybe on your screen.

Not with a screen width of 1200 and more.

Tuesday, January 29, 2008 8:58 AM by Bramley

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan

I have been working with content deployment in MOSS2007. It worked well before. Currently I'm getting the following error:

<?xml version="1.0" encoding="utf-8" ?>

- <ArrayOfReportMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <ReportMessage Title="Unknown compression type in a cabinet folder" Time="2008-01-29T13:40:31.2983868Z" Severity="Error" Phase="ExportInProgress" />

 <ReportMessage Title="Failed to create package file. at Microsoft.SharePoint.Deployment.ExportDataFileManager.<>c__DisplayClass2.<Compress>b__0() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.Deployment.ExportDataFileManager.Compress(SPRequest request) at Microsoft.SharePoint.Deployment.SPExport.Run() *** Inner exception: Unknown compression type in a cabinet folder at Microsoft.SharePoint.Library.SPRequest.BuildCabinetFile(String bstrTempDirectory, String bstrCabFileLocation, UInt32 uMaxCabFileSize) at Microsoft.SharePoint.Deployment.ExportDataFileManager.<>c__DisplayClass2.<Compress>b__0()" Time="2008-01-29T13:40:35.5170828Z" Severity="Error" Phase="ExportInProgress" />

 <ReportMessage Title="Content deployment job 'NewCompletePushTest' failed.The exception thrown was 'Microsoft.SharePoint.SPException' : 'Failed to create package file.'" Time="2008-01-29T13:40:49.9387732Z" Severity="Error" Description="" Recommendation="" Phase="Failure" />

 </ArrayOfReportMessage>

Here is the scenario:

I have just completed installing wss service pack 1, and MOSS 2007. The replication now gives the error above. My topology is as follows: I have two farms located in different located geographically. It was working before. This is a full-deployment not incremental.

please help

Tuesday, January 29, 2008 9:54 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Bramley,

please open a support case for this. This is not an issue I have heard about till now.

Cheers,

Stefan

Wednesday, January 30, 2008 12:03 AM by Bramley

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan

Do you think this has any thing to do with compression of files. How can I remove compression. I'm using MOSS - Central Administration for content deployment. This issue affect the increment updates. I get the following error for incremental:

<?xml version="1.0" encoding="utf-8" ?>

- <ArrayOfReportMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <ReportMessage Title="The changeToken refers to a time before the start of the current change log." Time="2008-01-29T20:39:04.6175572Z" Severity="Error" ObjectName="/" Phase="ExportInProgress" />

 <ReportMessage Title="The changeToken refers to a time before the start of the current change log. at Microsoft.SharePoint.Deployment.SPExport.ThrowInvalidChangeTokenError(DateTime minChangeTime, Int32 minChangeNumber) at Microsoft.SharePoint.Deployment.SPExport.GetIncrementalChanges() at Microsoft.SharePoint.Deployment.SPExport.CalculateObjectsToExport() at Microsoft.SharePoint.Deployment.SPExport.Run()" Time="2008-01-29T20:39:04.8363044Z" Severity="Error" Phase="ExportInProgress" />

 <ReportMessage Title="Content deployment job 'NewCompletePushTest' failed.The exception thrown was 'Microsoft.SharePoint.SPException' : 'The changeToken refers to a time before the start of the current change log.'" Time="2008-01-29T20:39:05.8362916Z" Severity="Error" Description="" Recommendation="" Phase="Failure" />

 </ArrayOfReportMessage>

Any help will do.

Wednesday, January 30, 2008 3:07 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Bramley,

sure it is related to compression. The error message implies this.

The error for the incremental deployment indicates that your database is older than the last deployment.

This can happen if you have restored an older backup of the database. Then the deployment job definition does no longer fit to the source database.

Cheers,

Stefan

Monday, February 18, 2008 3:21 AM by Eric.Chai

# SharePoint列表导入/导出命令

在使用SharePoint的时候我们常常需要做这样一个操作:把某个列表(或文档库)从一个网站转移到另一个网站上去。

比较常见的做法是,把这个列表存为模板文件,然后再在新的网站位置创建一遍。但这种方法...

Monday, February 25, 2008 2:53 PM by Mike's Blog

# Deep Dive Into the SharePoint Content Deployment and Migration API

Stefan Goßner posted a great series of posts about the Content Migration API (formerly known as PRIME

Wednesday, February 27, 2008 8:36 PM by Mirrored Blogs

# New version of Content Deployment Wizard released

I&#39;m happy to announce that development/testing of the next version of the SharePoint Content Deployment

Friday, February 29, 2008 12:45 PM by Ramesh

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi

I've a big problem in the stsadm -restore command

We only had Site collection backups and we need one site the user deleted from the backup

We did the backup in the production server and one of the user deleted the site(:)) and we’re trying to get the site backup.

When we try to restore we're getting the following error

C:\Documents and Settings\rameshk>stsadm -o restore -url http://localhost -filename z:\projects.bak -overwrite

Your backup is from a different version of Windows SharePoint Services and cannot be restored to a server running the current version. The backup file should be restored to a server with version '3701403.0.1196032409.29915337' or later.

I saw few post on this error.

http://blogs.technet.com/wbaer/archive/2007/05/22/understanding-and-handling-microsoft-it-site-delete-capture-1-0-archives.aspx - I did install the MSITDelete Site capture on my local machine. Not sure that is the problem. If only have installed this the production, that would have saved almost two days and still no postive results

http://serverdays.com/2007/08/10/problems-using-stsadm-to-backup-windows-sharepoint-services-30/

But not any solutions though. I don't know whether Microsoft knows about this or something I'm not doing correctly.

And by the way, if I have backup using stsadm can I read it using Content API or any other tool which wil read the data and restore it

Any help will be greatly appreciated.

Thanks

Ramesh

Friday, February 29, 2008 12:49 PM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Ramesh,

this message means that the backup has been taken using SQL methods - not using STSADM -o backup.

You need to restore it using SQL methods. You cannot restore a SQL backup with STSADM.

Cheers,

Stefan

Monday, March 24, 2008 1:48 AM by Vedanshu

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi,

I am using Microsoft.Sharepoint.Deployment classes to create archives of sites using the code mentioned below. It used to work previously, but has started throwing the following exception

Failed to create package file

Unknown compression type in a cabinet folder

at Microsoft.SharePoint.Library.SPRequest.BuildCabinetFile(String bstrTempDirectory, String bstrCabFileLocation, UInt32 uMaxCabFileSize) at Microsoft.SharePoint.Deployment.ExportDataFileManager.<>c__DisplayClass2.<Compress>b__0()

Here's the code that I am using

SPSecurity.RunWithElevatedPrivileges(delegate()

               {

                   using (SPSite site = new SPSite(url))

                   {

                       using (SPWeb web = site.OpenWeb())

                       {

                           string strBackupfile = web.Title + ".cmp";

                           SPExportSettings exportSettings = new SPExportSettings();

                           if (ExportAll)

                               exportSettings.ExportMethod = SPExportMethodType.ExportAll;

                           else

                               exportSettings.ExportMethod = SPExportMethodType.ExportChanges;

                           exportSettings.BaseFileName = strBackupfile;

                           exportSettings.FileLocation = "C:\\";

                           exportSettings.ExcludeDependencies = false;

                           exportSettings.IncludeSecurity = SPIncludeSecurity.All;

                           if (IncludeAllVersions)

                               exportSettings.IncludeVersions = SPIncludeVersions.All;

                           else

                               exportSettings.IncludeVersions = SPIncludeVersions.CurrentVersion;

                           exportSettings.SiteUrl = url;

                           exportSettings.ExcludeDependencies = false;

                           exportSettings.CommandLineVerbose = false;

                           exportSettings.FileCompression = true;

                           exportSettings.OverwriteExistingDataFile = true;

                           SPExportObject ob = new SPExportObject();

                           ob.Type = SPDeploymentObjectType.Web;

                           ob.ExcludeChildren = false;

                           ob.Id = web.ID;

                           exportSettings.ExportObjects.Add(ob);

                           exportSettings.Validate();

                           SPExport export = new SPExport(exportSettings);

                           //export.Completed += new EventHandler<SPDeploymentEventArgs>(export_Completed);

                           //Run the damn thing.

                           export.Run();

                           //context.Undo();

                       }

                   }

               });

This works correctly if I set exportSettings.FileCompression to false. I have recently installed WSS and MOSS service packs. Can you please help me out?

Thanks

Vedanshu

Tuesday, March 25, 2008 5:04 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Vedanshu,

this is a common error if the compression fails due to insufficient disk space.

Please monitor the available disk space during export.

Cheers,

Stefan

Tuesday, March 25, 2008 5:52 AM by Vedanshu

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan,

I am running this process on a test site which is just a basic collaboration portal. The process used to work fine before we installed Sharepoint service packs. During those test runs, the size of archives created was less than 10MB with the available disk space being close to 22GB. So I guess disk space should not have  been a problem. I have also tried it with different filetypes (.cmp, .cab etc.)but have not been able to run it with compression enabled. The process works correctly if exportsettings.FileCompression is set to false.

Thanks

Vedanshu

Tuesday, March 25, 2008 6:15 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Vedanshu,

please monitor the space on ALL your disks - not only the destiation disk where the final package should be created.

During export the files are temporarily created on the drive where the TMP environment variable points to.

Cheers,

Stefan

Friday, April 11, 2008 7:37 PM by Stefan Goßner

# Deep Dive into the SharePoint Content Deployment and Migration API - Part 6

[ Part 1 - Part 2 - Part 3 - Part 4 - Part 5 - Part 6 ] Requirements for a successful content deployment

Tuesday, April 22, 2008 9:57 PM by akhanna

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan,

I have a timer job running which uses export settings class and creates a content package for all the items in a document library.

Now users upload files in this document library and I want only the approved items should be exported.

If I SPIncludeVersions.LastMajor , and I have anything where approval status is pending, I get the error message that

The object with Id<Guid)  that was configured as part of the Export Settings no longer exists.

If I change SPIncludeVersions.CurrentVersion then it exports all items even if the approval status is pending.

what do I need to do that people can upload to this list and only documents with status of approved are exported.

Thanks In Advance.

Cheers

Ajay

Wednesday, April 23, 2008 2:54 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Akhanna,

the error should not occur. Please open a support case to get this problem analyzed.

Thanks,

Stefan

Thursday, April 24, 2008 9:31 AM by Andrew Connell [MVP MOSS]

# Fantastic article on WSS content migration / MOSS content deployment API

Fantastic article on WSS content migration / MOSS content deployment API

Thursday, April 24, 2008 10:49 AM by Mirrored Blogs

# Fantastic article on WSS content migration / MOSS content deployment API

If you&#39;ve been under a rock like I have apparently over the last few months, you might not have noticed

Monday, May 05, 2008 4:15 AM by Kieran

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan

Would you suggest using SharePoint content deployment to move new sites/sub-sites and content types created by users from their local virtual development environment?

Best Regards

Monday, May 05, 2008 5:56 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Kieran,

sites and sub-sites: yes

Content types: no. These should be deployed using custom features. Not using content deployment.

Cheers,

Stefan

Wednesday, May 07, 2008 9:43 PM by jinzhuli

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Stefan

I have a problem when i use Export to Backup a Web . Error Message: Failed to backup the web. Reason: Export ran out of memory while compressing a very large file. To successfully export, turn compression off by specifying the -nofilecompression parameter.

Thanks

jinzhuli

Thursday, May 08, 2008 2:51 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Jinzhuli,

the solution is clear: either go to a 64-bit environment where no similar memory limitations exist or use the parameter above to disable compression.

Cheers,

Stefan

Thursday, May 29, 2008 9:51 AM by Stefan Goßner

# Pimp My Content Deployment Job

As a follow up to my article series about the content deployment and migration API here are some tips

Monday, June 09, 2008 1:28 PM by kindohm.com

# SharePoint Site vs. Web exports/imports and Custom Layout Pages

SharePoint Site vs. Web exports/imports and Custom Layout Pages

Thursday, June 12, 2008 7:34 PM by Mirrored Blogs

# SharePoint Content Deployment API Article Series

Body: If you are deploying SharePoint you should take some time and read the following WSS/MOSS Content

Friday, July 25, 2008 4:27 PM by Timothy

# SPExportObject members

Can someone explain the difference between ExcludeChildren and IncludeDescendants?

Thanks

Saturday, July 26, 2008 5:21 AM by Stefan_Gossner

# re: Deep Dive into the SharePoint Content Deployment and Migration API - Part 1

Hi Timothy,

I have explained this in part 2.

Cheers,

Stefan

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker