Since I had to piece together how to accomplish the migration of a host-named site collection (HNSC) I had already setup in SharePoint 2013, from one farm to another, I figured I would outline exactly how to do it. In my case, I needed the HNSC to be in its own content database, I’m targeting a particular web app with the HNSC as opposed to using a wildcard web app to handle the hostnames, and all of this is assuming you have your rights setup to be able to carry out all of this; SQL, SharePoint farm account and otherwise. With that said…
First let’s lay out our parameters:
Source (Test) Farm HNSC parameters:
- Web app URL: webapptest.contoso.com
- Database Server: SQLContentTest
- Content DB: WSS_Contoso_Content_Test
- HNSC URL: hnsctest.contoso.com
- Svc Acct: Contoso\webappsvctest
Destination (Production) Farm HNSC parameters:
- Web app URL: webapp.contoso.com
- Database Server: SQLContentProd
- Content DB: WSS_Contoso_Content
- HNSC URL: hnsc.contoso.com
- Svc Acct: Contoso\webappsvc
Create your content database in the source (Test) farm:
- In Central Admin, go to Application Management, select Manage Content Databases
- Under the Web Application drop-down, select the web application you want to create the new content database under.
- Click Add a content database.
- Under database server, enter SQLContentTest.
- Enter the name of your new content database: WSS_Contoso_Content_Test
- Leave everything else default.
- Click okay. After a minute or so, your new database will be created.
Create your HNSC in the Test environment, using the new content database:
- Execute the following PowerShell command, as the Farm service account, inserting the destination parameters outlined at the beginning:
- New-SPSite http://hnsctest.contoso.com/ -contentDatabase WSS_Contoso_Content_Test -OwnerAlias Contoso\webappsvctest -HostHeaderWebApplication http://webapptest.contoso.com/ -Name “HNSC Test”
- Since we’re targeting a particular web application for the creation of this HNSC (as opposed to using a wildcard web app, with no site name specified), we’ll need to add the IIS host headers to the particular web app:
- On the server (2012) desktop, open Server Manager.
- Click Tools and select Internet Information Services (IIS) Manager.
- Drill down to the particular web app where you setup the HNSC. Right click and select Bindings.
- Click Add and in the Host Name section, enter hnsctest.contoso.com and click OK.
- Click Close.
- Repeat steps 1-5 on the other web front-ends, if you’re running in a load-balanced environment.
Create your content database in the destination farm:
- In Central Admin, go to Application Management, select Manage Content Databases
- Under the Web Application drop-down, select the web application you want to create the new content database under.
- Click Add a content database.
- Under database server, enter SQLContentProd.
- Enter the name of your new content database: WSS_Contoso_Content
- Leave everything else default.
- Click okay. After a minute or so, your new database will be created.
Create your HNSC in the Production environment, using the new content database:
- Execute the following PowerShell command, as the Farm service account, inserting the destination parameters outlined at the beginning:
- New-SPSite http://hnsc.contoso.com/ -contentDatabase WSS_Contoso_Content -OwnerAlias Contoso\webappsvc -HostHeaderWebApplication http://webapp.contoso.com/ -Name “HNSC Production”
- Since we’re targeting a particular web application for the creation of this HNSC (as opposed to using a wildcard web app, with no site name specified), we’ll need to add the IIS host headers to the particular web app:
- On the server (2012) desktop, open Server Manager.
- Click Tools and select Internet Information Services (IIS) Manager.
- Drill down to the particular web app where you setup the HNSC. Right click and select Bindings.
- Click Add and in the Host Name section, enter hnsc.contoso.com and click OK.
- Click Close.
- Repeat steps 1-5 on the other web front-ends, if you’re running in a load-balanced environment.
Now that we have our sites in place, let’s say you make a bunch of changes to your test environment and are ready to move them to production. Here are the steps to backup the site in Test in order to move it to Prod:
- Login via RDP as the farm account to one of the web front-ends in the Test environment.
- Open the SharePoint PowerShell command line interface (CLI).
- Enter the following PowerShell command to back the host-named site collection:
- Backup-SPSite http://hnsctest.contoso.com/ -Path C:\Backup\hnsc.bak
- Copy the hnsc.bak file over to one of the production web front-ends, into a folder at the root of C called Restore (for our purposes here).
Now we are going to restore the hnsc.bak file to our Prod HNSC.
- Login via RDP as the farm account to one of the web front-ends in the Production environment.
- Open the SharePoint PowerShell command line interface (CLI).
- Enter the following PowerShell command to back the host-named site collection:
- Restore-SPSite http://hnsc.contoso.com/ -Path C:\Restore\hnsc.bak -DatabaseServer SQLContentProd -DatabaseName WSS_Contoso_Content -HostHeaderWebApplication http://webapp.contoso.com/ -Force
Once you’re done with that, attempt to access your HNSC and make any custom changes you need for production! If you receive a 404 upon initial site load, you may need to either recycle the app pool on each web front-end or just perform an IIS reset. Happy SharePointing!
Leave a Reply