SharePoint 2007 – Move Content and Configuration Databases

If you’ve ever wanted to relocate your WSS 3.0 or MOSS 2007 content databases or configuration database from one SQL server to another, you’ve probably found very little documentation and very little written on this topic.  Below is my attempt to provide some guidance for these tasks.  The steps are fairly simple, but please remember to try all operations of this magnitude on a development or test environment before trying this on your production SharePoint environment.

Move SharePoint Content Databases

Several common reasons for needing to move a content database from one SQL server to another are:

  • Scalability (spreading the load of your SQL server across multiple SQL servers)
  • Disaster Recovery (your SQL server had a catastrophic disaster and you need to recover from that event)
  • Database Reorganization (you simply need to change the server that hosts your content database or rename the database)

Instructions for moving a content database from one SQL server to another

  1. Detach the content database from the source SQL server and copy the .mdf and .ldf to the target SQL server. (Note: while you are moving the database files your users will see “Cannot connect to content database” when visiting their site)
  2. Attach the .mdf and .ldf files on the target SQL server as a new database (Note: this is your opportunity to rename the database if you desire)
  3. Run the following stsadm commands from the command line on your SharePoint server to complete the move:  (Note: the deletecontentdb does not actually delete the database from SQL server, it simply disconnects the database from SharePoint)

stsadm –o deletecontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver source_SQL_server
stsadm –o addcontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver target_SQL_server

Move SharePoint Configuration Database

Several common reasons for needing to move your configuration database from one SQL server to another are:

  • Disaster Recovery (your SQL server had a catastrophic disaster and you need to recover from that event)
  • Database Reorganization (you simply need to change the server that hosts your content database or rename the database)

Instructions for moving a configuration database from one SQL server to another

  1. Backup configuration database from the source SQL server
  2. Restore the backup onto the target SQL server (Note: this is your opportunity to rename the config database if desired)
  3. Run the following stsadm commands from the command line on your SharePoint server to complete the move:  (Note: the deleteconfigdb does not actually delete the database from SQL server, it simply disconnects the database from SharePoint)

stsadm -o deleteconfigdb
stsadm –o setconfigdb -connect –databaseserver target_SQL_server -databasename databasename -farmuser your_farm_sql_account -farmpassword your_farm_sql_password

 

The complete syntax for the stsadm -o deleteconfigdb is listed below: (Note: there are NO options)

stsadm.exe -o deleteconfigdb

 

The complete syntax for the stsadm -o setconfigdb is listed below:

stsadm.exe -o setconfigdb

           [-connect]

           -databaseserver <database server>

           [-databaseuser <database user>]

           [-databasepassword <database user password>]

           [-databasename <database name>]

           [-hh]

           [-exclusivelyusentlm]

           [-farmuser]

           [-farmpassword]

           [-adcreation]

           [-addomain <Active Directory domain>]

           [-adou <Active Directory OU>]

4 Responses

  1. [...] Move Content and Configuration Databases [...]

  2. Interesting read. I am currently in the proces of executing a move of the SharePoint databases, but I am not sure on how I can move the various Shared Services databases (such as Profiles and Search). They are not listed to belong to a specific site and I am not sure what to do with them. Should I enter the same site for each of these databases so it’s added as an extra content database?? Not sure if it will work that way.

  3. Thanks for these great instructions. I am migrating from a single host SQLServer to a Cluster. Using your instructions, I successfully moved the config db but CA stopped working. I simply ran the config wizard on the CA host and that got everything working again. Today I will be moving the content dbs. Thanks again.

  4. Thanks for this article. I’d like to add an important warning : the stsadm setconfigdb is obselete. Instead psconfig should be used (it looks like it is very similar though)

    Here are related links :

    http://technet.microsoft.com/en-us/library/cc261712.aspx
    where microsoft says that setconfigdb is obselete.

    http://technet.microsoft.com/en-us/library/cc263093.aspx
    for details to “attach” your new config DB to SharePoint using psconfig.

    Hope this will help.

Leave a Reply

Logged in as westerfunk Logout »