Restore / Migrate a SharePoint Web Application to another farm from SQL Database Backup

When I tried to take a Web Application backup using PowerShell .I found the backup size is about 90 GB.

Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} 
-Item <WebApplicationName> [-Verbose]

When I tried to restore the backup.

Restore-SPFarm -Directory <BackupFolderName> -RestoreMethod Overwrite 
-Item  <WebApplicationName> [-BackupId <GUID>] [-Verbose]

It took about 2 days to be restored based on the current farm specifications.Therefore,The goal of this article is to outline the key steps of a SharePoint Web Application Migration from Source environment to Destination environment.

Note:In this article,

  • I consider the Destination farm is identical to Source farm in Configuration Database Build Number,Cumulative Update,Service Pack,Language Pack,Application Services,Number of instances ..etc.
  • I consider the Web Application only have one Content Database.

Steps :

1-In Destination farm,

  • Open Central Administration > Application Management > Manage Web Application > Click New to create a new web application with the same port and the the same content DB in Source farm.

managewebapplication

  • Create a new site collection  with the same URL in Test farm.

createsitecollection

  • Go back to Application Management > Manage Content database.

managecontentDB

  • Select the Web Application URL.

ContentDB

  • Click on Content Database name > Check Remove Content Database > OK.

RemoveContentDB

You can also use a SharePoint Management Shell to achieve the previous step by the following command.

Dismount-SPContentDatabase "<ContentdBName>"

The Dismount-SPContentDatabase cmdlet detaches the content database from the Web application, but it does not delete the content database from SQL Server. After a content database is detached, you cannot delete it by using Windows PowerShell 2.0. You can only remove it by using SQL Server tools. If you want to delete the content database from SQL Server while you detach it, use the Remove-SPContentDatabase cmdlet instead.

2-In Source farm,

  • Take a backup from web application content database.

backup

3-In Destination farm,

  • Restore the database backup with the content database in Source farm.(If it’s exist check overwrite from Options).

restoreDB

  • Go back to Application Management > Manage Content Database > Select web application > Click on Add a content database with the same name of the Restored Content Database

AddcontentDB

SetContentDB

Note :  During mountting the content database to web application you might get this issue

This content database has a schema version which is not supported in this farm

errorcontentdb

To solve this issue follow the mentioned steps in this article.

You can also use a SharePoint Management Shell to achieve the previous step by using the following commands.

Mount-SPContentDatabase "<ContentDb>" -DatabaseServer "<DbServer>" 
-WebApplication http://SiteName
Test-SPContentDatabase "<ContentDb>"
Upgrade-SPContentDatabase "<ContentDb>"

upgradecontent

  • The Site Collection should now been restored, verify by browsing to the URL of the site

After the Restore operation has been completed successful you should perform the following steps:

1-In Source farm, perform the following:

  • Copy  all DLL files in bin folder of web application in this path \\inetpub\wwwroot\wss\VirtualDirectories\[Web Application Port Number]\bin            and paste it to the same path in Destination farm.

bin in the test farm

  • Move all custom Folder/File systems to the same path in Destination farm with the required permission eg: [TempImageFiles] for charts.

2-In Destination farm, Install and Deploy all custom WSP solutions that deployed before in Staging farm.

Farm Solution List

To know How to install and deploy WSP solution check this article.

3-In Destination farm, Perform the following:

  • Update web.config of web application with all custom entries in web.config of Web Application in Staging farm.(Connection String,Chart Settings ,Custom Configurations ….etc).

compare web.config

compare Web Config

Note: you can use the online compare tool to compare between both web.config in Staging and Production.

4-Change Site collection administrator for the web application to avoid the access permission issue.

Enjoy 🙂

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