SharePoint on-premises – migrate site collection to new server

by | Jul 8, 2020 | Microsoft SharePoint

Here we’re going to discuss the cleanest way (we have found) to migrate an on-premises site collection to a new server. This only covers the situation where both the original server and new server are both running essentially the same version of SharePoint. i.e. this does not cover upgrading sites from one version of SharePoint to another. In terms of SharePoint updates and service packs, the destination SharePoint servers must be running the same or later version than the source SharePoint servers.

For the purposes of this discussion, we’re only going to consider a simple server farm, Web Front End plus SQL Server. It does not consider any additional steps required for large distributed server farms. However, the typical pain point in this type of migration is just getting the basic site transferred.

Source SharePoint web front end

On the source SharePoint server, identify the content database that contains the site collection. To do this:

  1. Open SharePoint Central Administration. Click on Application Management from the left menu. Under Site Collections, click on View Site Collections.
  2. On the Site Collection List page, select the required web application from the Web Application drop down.
  3. If you’ve selected the correct web application, you should now see the URL of your site collection. Click on the URL to get the details for that site collection.
  4. The table that displays will show Database Name. Make a note of this as this is the name of the content database.

Source SharePoint SQL server

On the SharePoint SQL server, you now need to create a backup of the content database identified in the steps above.

  1. Open SQL Server Management Studio.
  2. Locate the content database to backup using the name found above.
  3. Right click on the content database and from the pop-up menu select Tasks>Backup.
  4. On the General page of the Back Up Database dialog select:
    1. Backup Type = Full.
    2. Backup Component = Database.
    3. Destination > Backup To = Disk.
    4. Under Destination, click the Add button to select a folder and filename for the backup. Remember to include the filename including a .bak extension.
  5. On the Options page of the Back Up Database dialog select:
    1. Overwrite all existing backup sets.
    2. Verify backup when finished.
  6. Click the OK button to run the backup.
  7. Once complete, copy the backup file to the destination SQL server.

Destination SharePoint web front end

As mentioned above, this discussion only covers migrating a site collection between servers running essentially the same version of SharePoint, e.g. SharePoint 2013, SharePoint 2016, SharePoint 2019, etc. The source and destination servers can be at slightly different build versions but, in this case, the destination server must be at the same or later build number than the source server.

Create a new web application

First step is to create a new web application.

  1. Open SharePoint Central Administration.
  2. Click on Application Management from left side menu.
  3. Under Web Applications, click on Manage Web Applications.
  4. On the ribbon click on New to start the create web application wizard. Complete the create web application form as required. Under Database Name manually enter a name for the new content database that reflects the SharePoint site name (this just makes it easier to identify the content database when browsing SQL server using SQL Server Management Studio). i.e. use something like WSS_Content_MyNewSharePointSite_Port2134. Click the OK button to create the new site collection.

Create a new site collection

Once the web application is created you will be prompted to create a new site collection. If you are migrating a site collection that is using path based addressing then definitely follow the wizard to create a new site collection here. This will give you a new site collection with a URL such as http://mynewsharepointserver:2134 where 2134 is the port number you selected for your new web application.

If you the site collection you are moving is host named then it is recommended to also create a default path based site collection even though it will never really be used. SharePoint search often falls over if a web application hosting host named site collections does not host a default path based site collection.

Host Named site collection

If you are moving a site collection that is host named, you will need to create a new site collection using the same host name that is used on the source SharePoint server, e.g. http://www.mygreatsharepointsite.com. To do this you need to create the site using powershell using the following commands:

$template = Get-SPWebTemplate "STS#0"
New-SPSite http://www.mygreatsharepointsite.com -OwnerAlias mydomain\myname -HostHeaderWebApplication http://mynewsharepointserver:2134 -Template $template

The above will create a new blank team site collection. If your site collection is based on a different site template, you should use that as the template for creating a new blank site collection here.

Once you have created the new blank site collection, check that you are able to navigate to it before continuing.

Possible issues at this stage

There are a couple of possible issues at this stage. One is that your dns for www.mygreatsharepointsite.com is still pointing to the source SharePoint server. To temporarily get around this, edit the local hosts file for the machine you are using to access the new SharePoint server to point www.mygreatsharepointsite.com to the new SharePoint web front end server ip address.

Second issue is if you are trying to access the new site collection actually on the SharePoint web front end itself, you may be blocked from doing so by local loopback issues. To get around this issue you will need to add some entries to the registry on the SharePoint server web front end to either Disable the loop back check or to add Hostnames in the registry using a BackConnectionHostNames registry entry. Both methods are discussed in a blog post named Workaround For Loop Back Check Issue In SharePoint

Temporarily Remove Content Database

Once the new blank site collection is working, we can move on to restore the SQL database backup we made from the source SQL server. The first step here is to actually temporarily remove the SharePoint content database that hosts the new site collection. To do this.

  1. Open SharePoint Central Administration.
  2. Click on Application Management from the left menu
  3. Under Databases, click on Manage Content Databases.
  4. On the Content Databases page, select the correct web application using the web application drop down.
  5. With the correct web application selected, you should now see the content database created for the new web application, e.g. WSS_Content_MyNewSharePointSite_Port2134.
  6. Click on the content database link to open the Manage Content Database Settings page.
  7. Scroll down the page until you see the Remove content database checkbox. Tick this box.
  8. Click the OK button. This will remove the content database from SharePoint. This will not remove the content database from SQL server.

Destination SQL Server

On the destination SQL server we can now restore the database backup.

  1. Open SQL Server Management Studio and connect to the SQL server.
  2. In SQL Server Management Studio, expand the list of databases and locate the content database for the new site collection, e.g. WSS_Content_MyNewSharePointSite_Port2134.
  3. In order to ensure that the content database is not logged we are going to detach it and re-attach it to SQL Server. Right click on the database and select Tasks>Detach.
    1. On the Detach Database pop up, tick the checkbox to Drop Connections.
    2. Click the OK button. This will detach the database from SQL – it will disappear from the list of databases.
  4. In SQL Server Management Studio, right click on the root Databases folder and select Attach.
    1. On the Attach Databases dialog, click on the Add button.
    2. Locate the content database, e.g. WSS_Content_MyNewSharePointSite_Port2134.mdf, select it and click the OK button to re-attach it to SQL server.
  5. In SQL Server Management Studio, Right click on the database and select Tasks>Restore>Database…
  6. On the Restore Database pop up General page:
    1. Under Source, click to select Device
    2. Click on the  button. This will pop up the Select backup devices dialog. On this dialog, click the Add button and browse to find the backup file that was copied across from the source SQL server. With the backup file selected, click the OK button to close the dialog.
    3. Under Destination, reselect the name of the content database for the new site collection, e.g. WSS_Content_MyNewSharePointSite_Port2134.
  7. On the Restore Database pop up Files page:
    1. Double check the file locations that will be used for the restored database. These should be ok automatically.
  8. On the Restore Database pop up Options page:
    1. Select to Overwrite the existing database (WITH REPLACE).
  9. Click the OK button to restore the database to the new content database.

Destination SharePoint web front end

With the SQL server restored to the new content database, we can now add back the content database into SharePoint.

  1. Open SharePoint Central Administration.
  2. Click on Application Management from the left menu
  3. Under Databases, click on Manage Content Databases.
  4. On the Content Databases page, select the correct web application using the web application drop down.
  5. Click on the Add a content database link.
  6. On the Add Content Database page, under Database Name, add the name of the new content database, e.g. WSS_Content_MyNewSharePointSite_Port2134
  7. You can leave all other values at default.
  8. Click the OK button to add the content database.

Basically, your SharePoint site collection is now migrated and you should be able to access it on the new server. There may be a couple of other tasks that you need to do to complete the process.

Upgrade content database

If the source SharePoint server was at a slightly lower build number than the destination SharePoint server, you should upgrade the database. This can be done in powershell using the command:

Upgrade-SPContentDatabase WSS_Content_MyNewSharePointSite_Port2134

Give host named site collection a new URL

If you want to use a different URL for the migrated site collection to the one used on the source SharePoint server, you can rename the site collection in powershell using the following commands:

$site = Get-SPSite -Identity http://www.mygreatsharepointsite.com
$site.Rename("http://www.mynewgreatsharepointsite.com")

Restart IIS

Finally, you should restart IIS server.


aento provides a full range of consulting and support services for Microsoft SharePoint and Microsoft 365. Find out more

Let us keep you updated

Never miss an important update from aento.   Sign-up and we'll let you know by email when we've published a new blog post or if there is any important industry news related to online business.  You can unsubscribe with a single click at any time.

Thank you for subscribing.