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:

New-SPWeb -URL https://portal.contoso.com/sites/NewHome/MoveMe

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:

Remove-SPSite -Identity https://portal.contoso.com/sites/MoveMe

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

avatar

About Adam Preston

Adam is a Senior Consultant specializing in the administration and configuration of SharePoint. He holds several SharePoint certifications, including MCITP: SharePoint Administrator 2010. He is the Vice President of the Richmond SharePoint Users Group and active throughout the SharePoint community via Twitter (@_apreston) and MSDN Forums.
This entry was posted in Administration, PowerShell and tagged , . Bookmark the permalink.

14 Responses to Move a Site Collection to a Subsite in SharePoint 2010

  1. Pingback: Move a Site Collection to a Subsite in SharePoint 2010 « SP2010 Blog

  2. avatar uzn says:

    Adam, thanks for the article. Does the Export/Import moves the content database as well? I have site collection to move to the root. The site collection are used by customers right now. Shall i detach the content database and attach it to new site collection? Which approach is best suited?

  3. avatar ttt says:

    Hi,

    good description of the Export and Import Commandlets.

    But are you sure, you mean “Moving a Site-COLLECTION” under another site?

    As far as I know, a SiteCollection can only be the top of other SiteCollections??
    thomas

    • avatar Adam Preston says:

      Great question, but when I say moving I mean demoting a Site Collection to be a subsite under another Site Collection

      • avatar ttt says:

        Hi,

        ok, I see, thanks.
        BTW, did you try: What happens to the subsites of the source-SiteCollection, if the SiteCollection is being re-imported under another Site??

  4. avatar Glenn Baxter says:

    We have a 2007 WSS (SBS 2008) Site Collection to be moved – I see it is easier under 2010, what can I do if anythnig?
    Thanks.

  5. avatar Binit says:

    Hi everyone,
    Let me start with saying, great post. I have a different problem though. I am exporting a subsite using the central admin granular backup. Then importing that web using powershell and everything works like a charm. The only problem is that the list ID’s are not retained in import-export like they are in backup-restore of a site collection. Can anyone please help me with how to retain these ID’s.
    Thanks in advance for your help. :)

  6. avatar David says:

    What about if you want to do the reverse? You have a subsite that you want to promote to a site collection.

  7. avatar ank says:

    What if the source and destination are on different servers (may be of not same version too). Is there any way to do it?

    • avatar Adam Preston says:

      Just to clarify, when you say servers I’m assuming you mean farms.

      Not different SP versions: You can still use Export-SPWeb and Import-SPWeb, just move the export file(s) to the other farm prior to running the Import-SPWeb on that farm. Be aware that this includes security so we are assuming both farms are in the same domain.

      Different SP Versions: I would isolate the Site Collection to its on Content Database then use the database migration method – which mean moving the DB to the other farm and running upgrade tests on that database (Test-SPContentDatabase). Once the Site Collection is on the destination farm, then use the same steps in this post. Be aware that if you are going down in versions that the database may errorer out due to features not available on the destination farm.

  8. avatar John says:

    Hi Adam.

    Can I export a site without the subsites? I want to create a copy of a site collection, but just a partial copy (only some subsites), so if I can export just a single site I can build my new site collection peace by peace.

    Thx

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>