Saturday, May 9, 2015

Moving SharePoint Site Content to a new server

I recently had to perform a SharePoint Server Migration.  Unfortunately, I had never done this before and therefore was not sure of the best approach to accomplish this.

MSDN, unfortunately, also does not provide a whole lot of insight on how to accomplish this either.

Some forums indicated that if I had not made significant server configuration changes and most of my database was stored in Content Databases, I could simply install a fresh installation of SharePoint on my new server and then restore the content databases.

Therefore, based on my experience, I thought of possibly performing a Site Collection Backup and Restore to the new server using either Central Administration or PowerShell commands.

However, the Site Collections had grown rather large so I was hoping there was another way.

The first method I tried was simply doing a SQL Server database restore over my existing Content database.  Since I had name the Content Databases the same (using AutoSPInstaller), I thought that this might work and decided to give it a shot.

Well, thankfully, I was using a Virtual Machine snapshot in place before I did this because it failed miserably!!  The restored Content Database was not recognized at all!

So, after a little bit more research, I came across this MSDN article:

Attach or detach content databases in SharePoint 2013

Therefore, I decided to detach my old content database and then restore my new content database and subsequently attach the new content database to my appropriate Web Application.

Sure enough, this approach worked beautifully!  Not only did the restore occur effortlessly, it also captured all of the Site Collections present in my Content database and displayed all of the content that was there previously completely intact!

Therefore, detaching and attaching content databases via the SharePoint PowerShell cmdlets is definitely the way to go!!

Here are the PowerShell scripts that I used for your reference:
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$ContentDB = "SharePoint_Content_Portal"
#Dismount the Content Database
Dismount-SPContentDatabase $ContentDB

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$ContentDB = "SharePoint_Content_Portal"
$WebApp = ""
#Mount the Content Database
Mount-SPContentDatabase $ContentDB -DatabaseServer $DBServer -WebApplication $WebApp

No comments:

Post a Comment