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:

  1. In Central Admin, go to Application Management, select Manage Content Databases
  2. Under the Web Application drop-down, select the web application you want to create the new content database under.
  3. Click Add a content database.
  4. Under database server, enter SQLContentTest.
  5. Enter the name of your new content database: WSS_Contoso_Content_Test
  6. Leave everything else default.
  7. 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:

  1. 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”
  2. 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:
    1. On the server (2012) desktop, open Server Manager.
    2. Click Tools and select Internet Information Services (IIS) Manager.
    3. Drill down to the particular web app where you setup the HNSC. Right click and select Bindings.
    4. Click Add and in the Host Name section, enter hnsctest.contoso.com and click OK.
    5. Click Close.
    6. 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:

  1. In Central Admin, go to Application Management, select Manage Content Databases
  2. Under the Web Application drop-down, select the web application you want to create the new content database under.
  3. Click Add a content database.
  4. Under database server, enter SQLContentProd.
  5. Enter the name of your new content database: WSS_Contoso_Content
  6. Leave everything else default.
  7. 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:

  1. 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”
  2. 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:
    1. On the server (2012) desktop, open Server Manager.
    2. Click Tools and select Internet Information Services (IIS) Manager.
    3. Drill down to the particular web app where you setup the HNSC. Right click and select Bindings.
    4. Click Add and in the Host Name section, enter hnsc.contoso.com and click OK.
    5. Click Close.
    6. 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:

  1. Login via RDP as the farm account to one of the web front-ends in the Test environment.
  2. Open the SharePoint PowerShell command line interface (CLI).
  3. Enter the following PowerShell command to back the host-named site collection:
    • Backup-SPSite http://hnsctest.contoso.com/ -Path C:\Backup\hnsc.bak
  4. 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.

  1. Login via RDP as the farm account to one of the web front-ends in the Production environment.
  2. Open the SharePoint PowerShell command line interface (CLI).
  3. 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!