|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Using the Content Migration Object Model
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
Typically, the scenarios for content migration fall into the following categories:
Moving the contents of a site collection from one location to another.
Migrating only selected content files from one site to another based on specified criteria.
Exporting content for the purpose of having some process performed on it, and then re-importing it.
Regardless of the scenario, however, the basic steps are the same. Following are high-level steps performed in a typical migration operation, including some links to the related object model members for more information.
The first step is to decide on the content you plan to export. You use the SPExportSettings class to define these values for your export operation.
Determine which objects to migrate.
Using the content migration object model, you can export a site collection, a list, library, folder, file, or list item.
For more information, see the SPExportObjectCollection class.
Decide how much of an object's data you want to export. You can export all of an object's data and its dependencies, or you can choose to export only incremental changes.
To export incremental changes, you must decide whether to export data based on one of the following:
A particular date.
Changes made to a file since that last export (using the Windows SharePoint Services change log).
For more information, see the ExportMethod property.
Identify a location for the output file (the *.cmp file, which is also called a content migration package).
Determine what metadata you want to include when exporting the data. For example, what type of versioning information do you want to export (the default is the last major version)? Do you want to export user and group information (by default, no user or group information is included)?
If you want, place limits on the size of your content migration package (.cmp) files. If the content files in a migration operation exceeds the specified file size limit, the operation automatically creates additional .cmp files, as needed.
For more information, see the FileMaxSize property.
Indicate how to handle warnings and errors during the export operation (by default, the export operation does not stop when it encounters a warning or nonfatal error).
After the export is complete, a content migration package is created at the location you defined in SPExportSettings. This file consists of a set of files that contain the content included in the export operation and metadata that describes the structure of the content.
Determine what metadata to include when importing the data. For example:
How do you want the versioning information to appear (by default, versions are appended to files at the destination location)?
For more information, see the UpdateVersions property.
Do you want the objects to keep their original GUID? (By default, object identity is not retained.)
For more information, see the RetainObjectIdentity property.
Use this property with caution—databases do not permit duplicate GUIDs. This property is most commonly used when you have two Web sites that are mirror images of each other, or in a publishing scenario, to indicate whether a file on one computer is the same as the file on another computer.
This functionality is available in the object model only. You cannot retain GUIDs using Stsadm.exe or the websvcSitesWeb service.
Indicate how to handle warnings and errors during the import operation (by default, the import operation does not stop when it encounters a warning or nonfatal error).