RSS

From The Field: Move a Site Collection to New Content DB with New Managed Path

10 Jun

Many of clients have multiple site collection stored in the same content DB of the web application. And in some day, they will discover that one of site collection contents is growing so fast, and they decide to have a dedicated Content DB for this Site Sollection. Also they may want to change the Managed Path (url) of site, i.e.: from “http://hostheader/sites/sitename” to “http://hostheader/sitename”.

In this article, I will explain how I did these requirements in the following scenario:

1. I have a web application with url (http://sps:1), and all site collection under this web application shared the same Content DB (Name: WSS_SP01_Content_01)

2. I have 2 Site Collection (Host Header Root Site and HR Site):

  • Main portal Site Collection under Host Header Root Managed Path (/)


  • HR portal site collection under the managed path (/sites/hr/)


  • I want to move the “HR” site to a new Content DB called(WSS_SP01_HR_Content_01)
  • I want to change the url from (/sites/hr/) to (/hr/).

The Steps are (using PowerShell):

1. Open PowerShell – SharePoint 2010 Management Shell

2. Create Explicit Managed Path for target Web Application, and call it “hr

  • Enter the following line in PowerShell:
    New-SPManagedPath -RelativeURL “hr” -WebApplicationhttp://sps:1” –Explicit
  • The PowerShell Results are:

  • Check it from Central Administration > Manage Web Applications > Managed Path:

3. Create a new Content DB called “WSS_SP01_HR_Content_01”

  • Enter the following line in PowerShell
    New-SPContentDatabase -name “WSS_SP01_HR_Content_01” -WebApplicationhttp://sps:1” -MaxSiteCount 1 -WarningSiteCount 0
  • Max Site Count = 1, to make sure No farther Site Collection can be added to this Content DB
  • The PowerShell Results are:

  • Check it from Central Administration > Manage Web Applications > Managed Content Databases:

4. Back up Site Collection “/sites/hr” to prepare moving it

  • Enter the following line in PowerShell::
    Backup-SPSitehttp://sps:1/sites/hr” -Path “C:\HR_TempSC.bak” –force
  • Check the file on “C” Drive

5. Removing the Site Collection from old managed path

  • Enter the following line in PowerShell::
    Remove-SPSite -Identityhttp://sps:1/sites/hr” -GradualDelete -Confirm:$false
  • Check the current number of Site Collection of Main Content DB (WSS_SP01_Content_01) , It should be 2 ( minus the HR Site Collection)

6. Restoring Site Collection to new Managed Path “/hr

  • Enter the following line in PowerShell::
    Restore-SPSitehttp://sps:1/hr” -Path “C:\HR_TempSC.bak” -DatabaseServer “SPS” -DatabaseName “WSS_SP01_HR_Content_01” -GradualDelete -Force -Confirm:$false
  • Check the current number of Site Collection of Main Content DB (WSS_SP01_HR_Content_01), It should be “1”

7. Remove the backup files from the backup directory

  • Enter the following line in PowerShell:
    Remove-Item “C:\HR_TempSC.bak”

8. Check the old url of HR, It should be not exists


9. Check the new HR Site Collection url “http://sps:1/hr” :

10. Check the Site Collection Properties, Central Admin > Application Management > View all site collections

Conclusion

I move and change the managed path of the site collection as simple as described before using PowerShell script. It is easy, clear, and save my time. and the following is the list of scripts i used in article:

  1. New-SPManagedPath -RelativeURL “hr” -WebApplicationhttp://sps:1” -Explicit
  2. New-SPContentDatabase -name “WSS_SP01_HR_Content_01” -WebApplicationhttp://sps:1” –MaxSiteCount 1 -WarningSiteCount 0
  3. Backup-SPSitehttp://sps:1/sites/hr” -Path “c:\HR_TempSC.bak” -force
  4. Remove-SPSite -Identityhttp://sps:1/sites/hr” -GradualDelete -Confirm:$false
  5. Restore-SPSitehttp://sps:1/hr” -Path “C:\HR_TempSC.bak” -DatabaseServer “SPS” -DatabaseName “WSS_SP01_HR_Content_01” -GradualDelete -Force -Confirm:$false
  6. Remove-Item “c:\HR_TempSC.bak”

For farther information about Windows PowerShell for SharePoint 2010, you can visit: Windows PowerShell for SharePoint Foundation 2010 reference

I Hope this useful for you,

Thanks.

 

Tags: , , ,

4 responses to “From The Field: Move a Site Collection to New Content DB with New Managed Path

  1. Ammar

    July 8, 2012 at 7:48 pm

    Thanks for the great Article Ali.

     
  2. shaik

    July 29, 2015 at 7:55 am

    Good one. It’s helped me…..

     
  3. Karthikeyan Ganesan

    June 26, 2018 at 3:19 pm

    Why we use “-GradualDelete -Force -Confirm:$false” these parameters in the “Restore-SPSite” ?

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: