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>]

SharePoint 2007 – "Back" Link After Deleting a Site

After deleting a site in WSS 3.0 or MOSS 2007 the following page is displayed by default.  The “webdeleted.aspx” is a default application page provided by Microsoft, but it is easily customized.  In this article I will show you how to enhance this page to be more user friendly.

delete

The problem with this page is that the user is left hanging, with no links back to the parent site or site collection where the site was deleted from.  Below is a quick solution for adding a link labeled “Go back to parent site” to the top of this page.  When the steps are complete your users will see the following:

delete2

Steps for adding the “Go back to parent site” link.

  1. In notepad, open the file named “webdeleted.aspx” in the 12 hive, layouts folder (usually this is located at the following location: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS )
  2. Located the content placeholder tag: <asp:Content ContentPlaceHolderId=”PlaceHolderTitleBreadcrumb” runat=”server”>
  3. Add the following code inside the content placeholder:  <a href=”<%SPHttpUtility.HtmlEncode(SPControl.GetContextSite(Context).Url, Response.Output);%>”>Go back to parent site</a>
  4. Save the “webdeleted.aspx” file.

When you are finished the code should look like the following:

<asp:Content ContentPlaceHolderId=”PlaceHolderTitleBreadcrumb” runat=”server”>
     <a href=”<%SPHttpUtility.HtmlEncode(SPControl.GetContextSite(Context).Url, Response.Output);%>”>Go back to parent site</a>
</asp:Content>

SharePoint 2007 – Migrating Fileshare Files into Document Libraries using Migration Tool

We all know that SharePoint document libraries are much more functional that NTFS file shares because SharePoint provides a searchable, indexable metadata framework.  As a SharePoint consultant I am often asked the question: How do I migrate my documents from my file server into SharePoint?  The answer really has to do with answers to the following questions:

  • Do you want to retain the document CreatedBy and CreatedDate values?
  • Do you want to load the document metadata into SharePoint columns (Author, Document Title, Summary, etc.)?
  • How many documents do you want to move to SharePoint?
  • Do you need to fix the names of documents and folders that do not comply with the SharePoint 2007 naming standards? (see the file name rules and folder name rules at the bottom of this post)
  • Do you need to automated the process of importing documents?
  • Do you need complex logic and rules around what documents to import and their destination locations?
  • Do you need to inventory your documents before importing them?

I have used several techniques to move documents into SharePoint document libraries and below I highlight the benefits and drawbacks of each technique:

SharePoint File Upload

Out of the box SharePoint 2007 provides several options for uploading documents into SharePoint document libraries.  These options include: Upload Document dialog, Upload Multiple Documents dialog and Windows Explorer drag and drop.  None of these options allow you to include the document metadata or maintain the CreatedBy, CreatedDate values so they are of limited use.

Pros:

  • The tools are built into SharePoint (no additional software to purchase)
  • No deployment steps

Cons:

  • Document metadata cannot be loaded
  • File CreatedBy and CreatedDate attributes are lost
  • No auditing or batch process
  • Files and folders with bad names will fail to upload and stop your uploading process

Metalogix FileShare Migration Manager

On the more expensive side of the spectrum is FileShare Migration Manager by Metalogix.  This tool provides the most advanced features and functions of any of the tools I’ve seen.  This tool is a bit more expensive than the others, but if you are working on a large migration of documents into SharePoint and there are complex rules for importing those documents (file renaming, logic to determine the destination, logic based on the metadata) then this is the tool for you.

Pros:

  • Load many types of metadata and you can define complex logic and rules related to the metadata
  • Ability to inventory your documents prior to importing them
  • Auto generate sites, document libraries and folders
  • Advanced framework for writing custom transformations
  • Can be fully automated

Cons:

  • Most expensive tool of the ones I’ve looked at

DockIT for SharePoint 2007

Another great tool is DockIT for SharePoint 2007 by Vyapin Software Systems.  This tool is a fairly inexpensive tool that provides the basic features necessary to perform migrations from Fileshares into SharePoint.  While this tool lacks some of the more advanced features and complex logic for complicated migrations, this tool does a good job of moving documents into SharePoint and is quite easy to use.

Pros:

  • Fairly inexpensive tool (we purchased the tool for just under $1000 US)
  • Can load files and extract metadata from the documents
  • Can maintain the CreatedBy and CreatedDate values
  • Sophisticated file renaming and file filtering engine
  • Can be fully automated
  • Simple to use

Cons:

  • Limited in it’s ability to deal with complex migration issues

CodePlex – SharePoint Migration Framework

Last, but not least, is an open source tool on CodePlex called SharePoint Migration Framework.  This tool, and set of accompanying source code, is free to use but does require more experience and research to get up and running in your environment.  I wouldn’t recommend this solution for end-users but if you have SharePoint development experience (and plenty of time) this may be the best tool for you.  This tool comes in two parts: the FileShare Data Extractor (which extracts your fileshare files into the correct format) and the SharePoint Importer (which then loads the files into SharePoint 2007).

Pros:

  • It’s free
  • Can load files and extract metadata from the documents
  • Can maintain the CreatedBy and CreatedDate values
  • Source code is provided for you to extend it’s functionality

Cons:

  • More difficult to use and to configure for complex migrations
  • Requires programming changes to perform more complex tasks

 

I hope this summary of the current SharePoint 2007 fileshare migrations tools is useful to you.  Please add a comment if you find additional migration tools that warrant adding to the list.

Appendix: SharePoint 2007 File and Folder Naming Rules

File Naming Rules

  • Invalid characters: ” # % & * : < > ? \ / { | } ~ 
  • Cannot be longer than 128 characters
  • You cannot use the period character consecutively in the middle of a file name
  • You cannot use the period character at the end of a file name
  • You cannot start a file name with the period character

Folder Naming Rules

  • You cannot use the following characters anywhere in a folder name or a server name:  ~ # % & * { } \ : < > ? / | ”
  • Cannot be longer than 128 characters
  • You cannot use the period character consecutively in the middle of a folder name
  • You cannot use the period character at the end of a folder name
  • You cannot start a folder name with the period character