Ever had a need to backup or migrate the content (libraries, lists, etc.) of a subsite in SharePoint? The STSADM command-line tool makes it very easy. As you know, STSADM can be used to backup a site collection at the parent level by using the backup operation. However, there may be times in which you want to backup a subsite, either before patching your SharePoint farm or in efforts of migrating the subsite to another farm or web application. You can accomplish this task by using the export and import operations of STSADM. The following is an example of exporting the contents from a team subsite:
stsadm -o export -url http://portal/sites/hr/team -filename C:\SharePointBackups\hrteam.cmp -includeusersecurity
The includeusersecurity parameter preserves the user security settings.
To migrate this data to another farm or web application, you issue the import operation, as follows:
stsadm -o import -url http://portal2/sites/hr/team -filename
C:\SharePointBackups\hrteam.cmp -includeusersecurity
NOTE 1: When importing to a new SharePoint farm, the new farm must be at the same patch level as the old farm. Also, you may encounter an error stating that one or more features are not available in the new farm, but exist in old farm. In my case, I got the error "Could not find Feature S2SiteAdmin". To fix this issue, follow these three simple steps:
1. Copy the appropriate feature directory from the old farm to the new farm. The feature directories are located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES. In my case, I copied the S2SiteAdmin directory from the old farm to the new farm.
2. Install the feature on the new farm by using the installfeature STSADM operation and the relative path to the Feature.xml file in your particular feature directory. In my case, I ran the following command:
stsadm -o installfeature -filename S2SiteAdmin\Feature.xml -name S2SiteAdmin
3. Activate the feature on the new farm by using the activatefeature STSADM operation. In my case, I ran the following command:
Stsadm -o activatefeature -name S2SiteAdmin -url http://portal2/sites/hr/team
NOTE 2: You must pre-create the subsite in the new environment before attempting to import to it. Also, the newly created subsite must use at least the same site template as the subsite to be imported, though I recommend using the Blank Site template to ensure the import runs without any issues.
The export and import STSADM operations are particularly useful if you administer project workspaces or subsites of a PWA (Project Web Access) site and need a good backup of their associated content before installing updates to the SharePoint farm. The PWA site is easy to recover by using the existing databases related to Project Server (Archive, Draft, Published, Reporting), but any project workspaces or subsites of the PWA site may require recovery using the import operation detailed in this blog post.
This is an awesome post that we can always come back to throughout the year!
ReplyDelete