Friday, April 6, 2012

Adding a Content Database to a farm with different patch levels.

Attaching and Upgrading a SharePoint 2010 Content Database


I was recently tasked with the challenge of taking a content database from a SharePoint 2010 Farm, pre-Service Pack 1 and attaching it to a Post-Service Pack 1 SharePoit 2010 Farm.  Seems like a pretty simple task.  We can do this a number of ways, including Central Administration, STSADM or PowerShell. 

I personaly prefer Powershell for simplicity and how many options we gain by using it.  Here's a breakdown of some options for attaching a Content Database, granting access to domain account previously configured as Managed Accounts in your Farm and upgrading the Content Database. 

The following below assumes that Content Database has already been attached in SQL by our Database Administrator friends, and now we need to make use of it in SharePoint.  *FYI - DBA's do not like spaces in Database Names,  so when you create them, don't use names with spaces.*



Add Content DB:

Mount-SPContentDatabase "Content_Database_A" -Database Server "DBServerName"-WebApplication http://webappA



Here's a link for reference - http://technet.microsoft.com/en-us/library/cc825314.aspx
It's hardly a complicated or lengthy script, so you either save it as "AddContentDB.ps1" and run it or just paste it into the SharePoint 2010 Management Shell window. 



Attach and Upgrade a Content Database.


New Challenge - Attach a Content Database from a Farm with lower patch level. and then upgrade it once it's attached.  To solve this challenge we'll need to upgrade the database after attaching it.  Again our friend Mr. PowerShell will be able to help us.  


Mount-SPContentDatabase "Content_Database_A" -Database Server "DBServerName"-WebApplication http://webappA
Get-SPContentDatabase?{$_.NeedsUpgrade –eq $true} | Upgrade-SPContentDatabase -confirm

This will do 2 things here, with a prompt before starting the 2nd thing. 
#1)  This will Attach the Content Database
#2)  This will look for any content databases that need upgrading and prompt you to upgrade 1 or all of them. 



Attach a Content Database, Grant a  Domain Account access and Upgrade the Content Database.


Yet another challenge.  Attach a Content Database, grant access a Domain Account access (ideally also a ManagedAccount in your Farm) and upgrade the database after it's attached.


Mount-SPContentDatabase "Content_Database_A" -Database Server "DBServerName"-WebApplication http://webappA
$webapp = GetSPWebApplication "http://webappA"
$webapp.GrantAccessToProcessIdentity("Domain\AcountNameA")
Get-SPContentDatabase?{$_.NeedsUpgrade –eq $true} | Upgrade-SPContentDatabase -confirm


This probably isn't a very common situation.  But if you're running Office Web Apps as a Domain Account, different from your Web Application Account, you'll need to grant the OWA account access to the Content Database.  I'm creating a topic for another post, but something to note, the Office Web Apps Cache is part of each Content Database so the account will need access. 







No comments: