Tuesday, January 19, 2016

Change host-named for site collection in SharePoint 2013

Today I'm facing with problem to change host-named of existing site collection to another. It takes me a lot of search with some issues in each steps. So I think that will be useful if I summarize something here to save my time in future and your time also.

In short, what I do exactly is:
 - Create new site collection with new domain
 - Deploy the website on it
 - Backup old site collection, then Restore on the new site collection

Before the begin, lets define some addresses I will use in detail steps.
WebCollectionAddr : that's the web collection address, ex: sharepoint-123:8888
OldSiteCollectionAddr : that's the old site collection address, ex: sharepoint-123:8888/sites/mysite
NewSiteCollectionAddr : that's the new site collection address, ex: mysite.com
I will use those above sites to demonstrate in each steps, so you should change it by your own sites.
Now we go in detail each step:

1. Create IIS binding for domain: 
 - Go to IIS Manager, click on your site under 'Sites'. You can see 'Bindings...' somewhere in the right content, click on.
 - Click 'Add'to add new and follow the step to create new site binding.

2. Create new site collection
 - Use sharepoint Powershell:
New-SPSite ‘http://NewSiteCollectionAddr/’ -HostHeaderWebApplication ‘http://WebCollectionAddr’ -Name ‘My site’ -Description ‘This is my site’ -OwnerAlias ‘domain\account’ -language 1033 -Template ‘STS#0’

 - Note: domain\account that account to login and have permission to create site collection

3. Check site is created
 - Use sharepoint Powershell:
Get-SPSite 'http://NewSiteCollectionAddr/'

4. Deploy the web site
 - Deploy the web site in the new site collection

5. Backup the old site collection
 - Use sharepoint Powershell:
Backup-SPSite 'http://OldSiteCollectionAddr/' -Path 'D:\SPBackup\bk_name.bak'

6. Delete old site collection
 - Go to sharepoint Central Administration > Application Management > Delete a Site collection
 - Select the old site collection then delete it

7. Remove the old site collection from recycle bin
 - After deleted, the site collection go to recycle bin, to restore data to new site collection, you should completely delete old site collection
 - To do that, you should get site id of old site collection from database 'AllSites' table
 - Use sharepoint Powershell:
Remove-SPDeletedSite -Identity 'GUID_SITE_ID'
 - Note: GUID_SITE_ID will be changed by site id, usually is guid text

8. Run Gradual Site Deletion Timer Job
 - Go to Central Administration > Monitoring > Review Job Definations.
 - Click on job name: Gradual Site Delete. Click on Run now.

9. Restore to new site
 - Use sharepoint Powershell:
Restore-SPSite 'http://NewSiteCollectionAddr/' -Path 'D:\SPBackup\bk_name.bak' -HostHeaderWebApplication ‘http://WebCollectionAddr’ -Force

Follow those steps, if you have any futher issue please comment in this blog.

Thank you.

No comments:

Post a Comment