March 31, 2011

How to Move a SharePoint site from one site collection to another

Here we got a requirement like moving a site collection from one division to another; the simple way to do is STSADM.EXE.
And steps are as follows:
Move Top Level Site to Sub Site
First, I had a top level site in it's own web application that needed to be a sub-site in another web application.  I've illustrated in the graphic below.  We had to move Site 1 from Site Collection 1 to Site Collection 2.


To export I used:
  • stsadm.exe -o export -url http://Site1 -filename Site1.cab -versions 4
To import I used:
  • stsadm.exe -o import -url http://SiteA/Site1 -filename Site1.cab
Notes
  1. If http://SiteA/Site1 already exists when you do you import you may see an error telling you the templates don't match.  This means the export site was created using a different template to the one that exists in the new location.  To workaround this back up and delete http://SiteA/Site1 then run the import again.
  2. Any content that hasn't been approved will not be exported by default.  I used the -versions 4 switch to export all major, minor and draft versions.  You might not need to do this.
Move Sub Site to Top Level Site
Next I needed to move a sub site in Site Collection 1 and move it into an empty Web Application 2.  In the figure below we had to move Site C from Site Collection 1 to Site Collection 2.

For the export I used:
  • stsadm -o export -url http://SiteA/SiteC -filename SiteC.cab -versions 4
Because there was no site collection I created one with STSAdm without choosing a template.  Like this:
  • stsadm.exe -o createsite -url http://SiteC -ownerlogin domain\administrator -owneremail administrator@domain.com -title Site C
That way you don't get any template clashes when you do your import:
  • stsadm.exe -o import -url http://SiteC -filename SiteC.cab
Notes
  1. An export should take all content with it.
  2. Custom features that have been installed on the source server will need to be packaged up and installed on the target before the import will work.
  3. It does matter which account you use for the export.  Strangely, if you don't have the right access the command runs successfully but the export file has got nothing in it.  The import doesn't fail either, but you can't find the site you thought you exported.   I've tried with an account that had local admin rights and was a site collection admin, but that isn't enough.  Always use the farm account.

No comments:

Post a Comment