Thursday, 25 November 2010

Move a SharePoint site or sub-site to another area within the same Farm or other Farms

Had a situation recently where I needed to promote a subsite to a top level site. As STSADM backup/restore can only be used at the site collection level, a different approach was required.
As of WSS v3, there are two new STSADM commands - import and export.
The basic procedure to promote the subsite was to STSADM export the site to a file and then STSADM import it at the toplevel.
Here are the basic commands I used:

Export subsite
stsadm -o export -url http://toplevel/sub_site/subsite -filename c:\subsite.bak -includeusersecurity -versions 4

Import subsite
stsadm -o import -url http://toplevel/subsite/ -filename c:\subsite.bak -includeusersecurity

A couple of things to note:
The -includeusersecurity switch ensures that all the columns such as modifed by, created by are maintained.

The -versions 4 switch will ensure that all versions of list items/documents are exported.

You must import/export to sites that share the same template. So a team site can only be exported and imported into another team site. You will know you are trying to import into non matching templates if you get the following error:

"The exported site is based on the template STS#1 but the destination site is based on the template STS#0"

This means that a site based on the blank template is trying to be imported into a site based on the team template. To my knowledge there is no easy way of changing a sites templates.
The following lists some of the common WSS templates:

Team Site STS#0
Blank Site STS#1
Document Workspace STS#2
Wiki Site WIKI#0
Blog BLOG#0

No comments: