Tuesday, August 7, 2012

How To Move a Site Collection to a Subsite in SharePoint 2010

During an upgrade and reorganization, we had a customer with a requirement to move a Site Collection to be a subsite of another Site Collection. Thankfully, with the new PowerShell capabilities with SharePoint 2010, this task was rather simple.
High-Level Steps

  • Export the Site Collection
  • Create the New Subsite
  • Import the Exported Site Collection
  • Delete the Old Site Collection
We have a Site Collection at /sites/MoveMe with a subsite under it at /sites/MoveMe/MoveMe2. We want to relocate this Site Collection under an existing Site Collection at /sites/NewHome.



Follow the steps below to move the site. All of the actions are performed using the SharePoint 2010 Management Shell.

Export the Site Collection

Execute the following command, substituting in the proper Identity parameter for your environment:


Export-SPWeb -Identity https://portal.contoso.com/sites/MoveMe -Path "C:\MoveMe.bak" -IncludeUserSecurity -Compression 1024 -IncludeVersions 4

Note the additional parameters of IncludeUserSecurity, Compression, and IncludeVersions. IncludeUserSecurity is pretty self-explanatory, but Compression will make sure to limit the number of multiple backup files for larger Site Collections, while IncludeVersions 4 says to include all versions for files.
TechNet for Export-SPWeb

Create a New Subsite

The import command requires that a site exist prior to importing. Therefore, we need to make an empty subsite for our soon-to-be relocated site:

Import the Exported Site Collection

Now that we have our exported Site Collection and our empty subsite, we can run the import command to relocate our site:


Import-SPWeb -Identity https://portal.contoso.com/sites/NewHome/MoveMe -Path "C:\MoveMe.bak" -IncludeUserSecurity

Once completed, we can navigate to /sites/NewHome/MoveMe and see that the site now exists in the new location as a subsite. If we navigate to MoveMe2 and use the folder icon, we can confirm that it is now a subsite under MoveMe, which is now a subsite under NewHome:


TechNet for Import-SPWeb
 
Delete the Old Site Collection

To clean everything up, we need to delete the old site collection. We perform this step last just in case we experience issues with the middle steps and need to start over:


(then Y to Confirm, or include the -Confirm parameter to auto-confirm)

No comments:

Post a Comment