Wednesday, October 5, 2016

Without backup/restore, how to change managed path of a site collection?

Based on the answer from Microsoft, backup/restore is the only way to change site collection managed path.

"backup/restore" actually copy the whole site collection to a file, then re-import it into SharePoint farm. This approach works well. But, instead of external file, we can also use a temporary database to hold the site collection data. Comparing to "backup/restore", it's much faster.

Below is the PowerShell script.

Mount-SPContentDatabase -AssignNewDatabaseId -Name SP_Content_Tmp -DatabaseServer $DatabaseServer -WebApplication $WebAppUrl

Copy-SPSite -Identity $SiteUrlSource -DestinationDatabase SP_Content_Tmp -TargetUrl $SiteUrlDest

Remove-SPSite -Identity $SiteUrlSource -confirm:$false

Get-SPTimerJob -WebApplication $WebAppUrl job-site-deletion | Start-SPTimerJob

Move-SPSite -Identity $SiteUrlDest -DestinationDatabase $ContentDatabase -Confirm:$false

Get-SPTimerJob -WebApplication $WebAppUrl job-site-deletion | Start-SPTimerJob

Dismount-SPContentDatabase -Identity SP_Content_Tmp -Confirm:$false

[update, 2016-10-19]

Windows Form program to generate PowerShell script:

No comments:

Post a Comment