Monday, February 26, 2007

MOSS 2007 - Import/Export Lessons Learnt

On my current project, we are required to use the stsadm export/import switch to move team sites to their new information architecture ('/sites/sitex' type syntax is not really required any more if you are happy for the sites to belong to the top level site collection). In addition to this, we wanted to migrate a site from another MOSS box to the new site. Once again we tried the export/import, but it didn't work.

Closer inspection revealed that although the export appeared to work (i.e. we got a success message), closer scrutiny of the export log shows that not all objects were correctly exported (in our case, some of the list definitions). This was due to the account that we were logged in as. We did not have read-write access to the database. Logging on as a local administrator with full privilege to the database resolved this problem.

The second problem we had was to do with migrating subsites (not site collections). We found that you can only import them to a top sub level site – and only if you first create a blank sub site with the same name first. This is the opposite when importing site collections – you can import them without first having to create a blank site, and you can import them anywhere in the site (not just straight under the top level site collection).

So once you’ve got the thing successfully imported at a top sub site level, you can easily move them around using the 'Manage Content and Structure' GUI interface.

FYI, the syntax for an export is:
stsadm -o export -url http://myserver/mysubsite1/mysubsite2 -filename c:\backup.dat -overwrite
the syntax for an an import is:
stsadm -o import -url http://mynewserver/mysubsite2 -filename c:\backup.dat


Unknown said...
This comment has been removed by the author.
Unknown said...

Hi Alan,
Thank for a useful tip. I have a question that you may be able to answer with regards to imports/exports of site collections into sites. I have a site collection which I'm trying to "convert" to a site using the proccess you described in your post. I manage to export site collection without any dramas but when I try to import it to a site it thows a few errors in a log like:

FatalError: Value does not fall within the expected range.
at Microsoft.SharePoint.SPList.GetItemById(Int32 id, String strRootFolder, Boolean cacheRowsetAndId)
at Microsoft.SharePoint.SPList.GetItemById(Int32 id)
at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupInListItem(ListItemLookup brokenField)
at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookup(DeploymentLookupField brokenField)
at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupsForObject(Guid sourceObjectId, Dictionary`2 brokenFieldMap)
at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupsForListItem(Guid sourceLookupItemId)
at Microsoft.SharePoint.Deployment.ListItemSerializer.FixBrokenLookups(SPListItem listItem, SerializationInfoHelper infoHelper)
at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject)
at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
at Microsoft.SharePoint.Deployment.SPImport.Run()

And although the site seems to be created, and users+groups imported too, the group permissions don't seem to be applied anymore. Here is the commands I used for my import/export:

1. stsadm -o export -url "http://myhost1/sites/site1" -filename "c:\site1" -includeusersecurity -versions 2

2. Create a new blank site called site1 on the destination server. Transfer the export file to destination server.

3. stsadm -o import -url http://myhost2/site1/ -filename C:\site1.cmp -includeusersecurity -quiet