Restore / Migrate a SharePoint Web Application to another SharePoint farm Using Database Attach method

In this article, I’ll show

How to migrate a web application from one farm to another in SharePoint 2013 / 2010 via database attach upgrade method?

Before we getting started, you should be aware of

warning-iconIn database attach upgrade method, The destination farm build number must be higher than the source farm build number or at least the same build number of source farm (Not lower than the source farmto avoid this error “This content database has a schema version which is not supported in this farm”

errorcontentdb

In the case of using Backup-SPFarm & Restore-SPFarm cmdlets, The destination farm build number must be the same as or higher than the source farm build number.

noteTo determine the build number of your source farm Check Find the latest Cumulative Update / Farm Patch Level that has been installed in a SharePoint Farm

You cannot backup and restore the database to the same farm using. Each site collection within the farm has a unique ID, which is not changed during the database restore process. Instead, you must use Backup-SPSite and Restore-SPSite which changes the ID of the Site Collection that is restored.

SharePoint Web Application Migration Steps:

  • In source farm,
    • Specify the web application content database.
    • Backup the content database.
    • Backup all the deployed  SharePoint solutions (WSP).
  • In destination farm:
    • Prepare your SharePoint destination farm.
    • Create a new web application, site collection.
    • Take a full database backup for the web application content database to enable the rollback if the migration process failed.
    • Dismount the web application content database.
    • Restore the database backup that taken from source farm.
    • Mount the content database for the web application.
    • Test the mounted content database.
    • Upgrade the mounted content database.
    • Deploy the custom WSP SharePoint solutions.
    • Change the site collection administrator.

SharePoint Migration Steps in details:

SharePoint 2013 Migration Steps in source farm, 

  • Specify the web application content database.
    • Open SharePoint Management Shell as Administrator.
    • Run the Get-SPContentDatabaseto list all web applications with their content database.
  • Take a full database backup from the web application content database.
    • Open SQL Server Management Studio.
    • Connect to SQL Server instance.
    • Backup the content Database.

hint-iconIn case,  the web application have more than one content database. you should backup all web application content databases

  • Backup your custom WSP SharePoint solutions.
    • Create a ‘WSPSolutions’ folder at any location.
    • Open SharePoint Management Shell as Administrator.
    • Run the below cmdlets to backup all the deployed WSP solution on your farm.

$FolderPath = "c:\WSPSolutions"
foreach ($solution in Get-SPSolution)
{
$id = $Solution.SolutionID
$title = $Solution.Name
$filename = $Solution.SolutionFile.Name
$solution.SolutionFile.SaveAs("$FolderPath\$filename")
}

For more details check How to install and deploy WSP solution 


SharePoint 2013 Migration Steps in destination farm, 

  • Create a new web application, site collection.
    • Open Central Administration > Application Management > Manage Web Application > Click New to create a new web application.
    • Once the web application has been created, create its site collection.
  • Take a full database backup for the web application content database to enable the rollback if the migration process failed.
    • Open SQL Server Management Studio.
    • Connect to SQL Server instance.
    • Backup the content Database.
  • Dismount the web application content database.
    • Via SharePoint Management Shell.
      • Run the Dismount-SPContentDatabase cmdlet to de-attach the content database from its web application.
Dismount-SPContentDatabase "content database name"

hint-iconThe Dismount-SPContentDatabase cmdlet detaches the content database from the Web application, but it does not delete the content database from SQL Server.but it does not delete the content database from SQL Server.

    • Via Central Administration:
      • Open Application Management > Manage Content database.
      • Select the Web Application URL.
      • Click on Content Database name > Check Remove Content Database > OK.
  • Restore the database backup that taken from source farm.
    • Open SQL Server Management Studio.
    • Connect to SQL Server instance.
    • Restore the content Database as shown below.
  • Mount the content database for the web application.
    •  Run the Mount-SPContentDatabase cmdlet to attach the content database from its web application.

noteTo attach a content database to a web application by using Windows PowerShell, Verify that you have the following memberships:

  • securityadmin fixed server role on the SQL Server instance.
  • db_owner fixed database role on all databases that are to be updated.
  • Administrators group on the server on which you are running the Windows PowerShell cmdlets.
Mount-SPContentDatabase "" -DatabaseServer "" -WebApplication http://SiteName
  • Test the mounted content database.
Test-SPContentDatabase "content database name"
  • Upgrade the mounted content database.
Upgrade-SPContentDatabase "content database name"

upgradecontent

  • Deploy the custom WSP SharePoint solutions.
    • Copy the WSPSolutions folder from the source farm to destination farm.
    • Perform a bulk WSP SharePoint solutions deploy using https://spsd.codeplex.com/ 
    • From source farm, copy all DLL files in the bin folder of the web application located in  \\inetpub\wwwroot\wss\VirtualDirectories\[Web Application Port Number]\bin
    • Paste it into the same path in destination farm.
  • Update web.config of the web application with all custom entries in web.config of Web Application in Staging farm.(Connection String,Chart Settings ,Custom Configurations ….etc).

Note: don’t use any online text compare tool to check the difference between web.config files, these files have a sensitive data, so it’s heavily recommended to use an offline tool like Windiff.exe Utility

  • Change the site collection administrator.
    • Open Central administration > Application Management > Chanage the site collection administrator.
    • Select the site collection > Set the new site collection administrator.

Applies To
  • SharePoint 2013.
  • SharePoint 2010.
Conclusion

In this article, I have explained

How to migrate from one farm to another in SharePoint 2013

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s