Skip Ribbon Commands
Skip to main content

Ben There, Done That

:

SharePoint Ben > Ben There, Done That > Posts > Moving SharePoint Databases to a new SQL Server – Part 2
March 17
Moving SharePoint Databases to a new SQL Server – Part 2

Sorry Part 2 has taken a little while in coming, I spent the last few days with my girlfriend and driving from MI down to FL. Anyways, you probably don't care about that, you just want to know what I did to move the rest of my databases, so here it goes.

After moving all your content databases over, the next thing to do is to move the config database. Microsoft actually provides a pretty straight forward way to do this. Start by taking a backup of your SharePoint config database and restoring it to your new SQL Server. Once it is restored there you can run stsadm –o setconfigdb. The flags that you can set along with this command allow you to set your newly moved Database as the new config database. This is where the fun starts. Many of you have done this and then reported that you still get errors about access the old SQL Server. A co-worker and I decided to dig into this a little more and found that in Central Admin under Operations -> Servers in Farm, it showed our old SQL Server as having the configuration databases, even though it was completely removed.

This is where the dive into the SharePoint Databases began. I opened up the SharePoint Configuration Databases and started digging and quickly discover a couple of tables that I could change a few rows in and solve all my problems. The first of these was dbo.Objects and the second dbo.Dependancies. In my objects table I still had an entry for my old SQL Server and a GUID tied to that Server. I took the GUID from my old SQL Server and did a query to find what it was the parent of and discovered it was the parent of the databases instance (which has a blank name if you are using the default instance). I took the GUID of the SQL instance, did a query and found that in this database, it was still the parent ID for my Config databases!! I had a good backup of my database so I figured what the heck, let's change this. So, I found the GUID for the instance of my new SQL Server, and executed an update query to change the ParentID GUID of my configuration database to the GUID that matched my new SQL Instance. I then ventured back in Central Admin and found to my excitement, that the Configuration Server listed about in my Servers in Farm was now changed to my new SQL Server. So far so good…but then I looked at my event log.

Still getting errors, so I thought maybe it was because my original SQL Server was still in my Server list in Operations -> Servers in Farm. I tried to remove it, but receive an error from SharePoint about dependencies…another table in my SQL Database. I decided to take a look and see in here. I found by executing queries on the database that there were still dependencies on my old SQL Server, particularly for different things relating to Alerts. Again, I had a backup, so I changed everything in my dependencies table by executing an update query that replace any GUID referencing my old SQL instance with a reference to my new SQL instance. I was still getting errors when trying to remove the SQL server and it dawned on me, that all my SharedServices databases were still listed as having a ParentID of my old SQL Server in my objects table. So, I went back to my SQL Server, did a backup and restore of all my SharedServices databases to my new Server, opened up another query windows and this time updated the ParentID of all the SharedServices databases in my objects table to the GUID for my new SQL Server. After an IIS reset, just to make sure, everything was still working!! Every reference in SharedServices was to my new SQL Server, all my databases were offline on my old SQL Server and everything worked!! I checked my error log and was still getting a few random errors. I restarted the server just to clear anything that had gotten cached somehow before I went any further.

That did it! After the reboot ALL my SharePoint errors in the event log were gone and everything seemed to be running! I had successfully moved over all my SharePoint databases, not lost any information and wasn't receiving any errors. Unfortunately, in the few days that have followed, I've found a few minor problems I'm still trying to work out and figure out if they are related to the move or not. The first is that PerformancePoint doesn't recognize SharePoint as being configured when trying to install the WebParts for PPS. The second is that there seems to be weird permissions issue with IIS as any site on my SharePoint server that isn't anonymous access, NTLM or Kerberos prompts for a username and password, but won't accept even an admin password. This is happening with my Forms Authentication site as well as with a generic .NET site running on the server. If anyone has any ideas I would love to hear them and I'll keep you updated on what I find.

I'm sorry this is a longer post, but hopefully you will all find this helpful and worth the longer post.

 

 Comments

 
 
 
 
 
 
 
 
 
 
 

Glad you liked it. Would you like to share?

Sharing this page …

Thanks! Close

Add New Comment

 

Showing 0 comments

    Trackback URL
     
    blog comments powered by Disqus
     

     Pre-Disqus Integration Comments

     

    Comments

    Moving SharePoint Databases to a new SQL Server – Part 2

    @John S 

    Hi John - Ineresting solution here, just one question, when you create the new databases and you say you eventually delete the old ones, will this not lose all the data for the site(s) as i believe the data is stored in SQL? Or does it pull the SQL content into the new databases when you restore the web apps\site collections? Hope this makes sense.  Thanks
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM

    Moving SharePoint Databases to a new SQL Server – Part 2

    All
    I’m certainly no SharePoint expert (not even close) but this is what I did to fix this problem. I researched a lot and I believe that you have to create a new farm to fix this issue. This is pretty easy though. Heres what I did:

    -On the old farm, go to central admin, application Management, Web application list. Make a note of all these applications and the URLs associated with them
    -Go back to Application management, click Site Collection List. Make a note of each site collection you have including the URL. Make sure to check each web app by selecting it on the right hand drop down and check the site collections in each app.
    -Now you have a list of all the things you need to back up. Yay!
    -use STSADM to back these up with the following command. You will run stsadm once for each entry you have noted in the steps above. I put my backup files in a folder called “Backup” on my servers C drive so my backup commands look like this:

    Stsadm –o backup –url http://mywebapp –filename c:\backup\mywebapp.dat

    -You will run this again for each webapp or site collection in your list. The command you use when backing up Site collections should contain the full URL including the host web app, even if you have already backed up the host webapp before. (I’m not sure why the backup doesn’t include site collections). So in my example, if I had a site collection at  ”/sites/projects” under http://mywebapp then I would need to run stsadmin again like this:

    Stsadmin –o backup –url http://mywebapp/sites/projects  –filename c:\backup\projects.dat

    -After you have a backup of all your webapps/site collections, move onto building your new farm.
    -On a new server, install SharePoint following whatever docs you need to make a good vanilla SharePoint install. I installed mine following the numerous TechNet articles available. It’s not a big deal. Took about an hour or 2. Pay attention to the persmisions sections!
    -Choose to create a new farm.
    -Once your new server is up and running, you will need to create all your webapps again. I don’t believe that you need to re-create your site collections – just the webapps. That’s what I did anyway.
    -Go to central Admin, application Management, Create or extend Web application.
    -Create a new web application for each of your old applications (not site collections) based on the list you created at the beginning. Again follow the M$ literature to do this properly (creating app pools, permissions etc – it’s not hard at all)
    -At this point its worth noting that I am creating my content DBs on the same DB server that my old content DBs are on. I’m calling them sensible names though so that I can distinguish between new DBs and Old ones and go back and delete old ones later.
    -copy all your backup files from your old server to your new one. In my example I’m copying them to “C:\backups” again
    -Now  change your DNS so that your old web app names now point to your new sharepoint server. This is important for the restore command to find your new server instead of the old one!
    -We use stsadm again to import the data from the backup files into the new web applications by running the following command from the new server:

    Stsadm –o restore –url http://mywebapp –filename c:\backups\mywebapp.dat

    -You run this command for each of your webapps that you backed up.  Once you have done all your webapps, restore your site collections by running stsadm again. You don’t have to recreate anything first (other than the host webapp which is hopefully already done)

    Stsadm –o restore -url http://mywebapp/sites/projects –filename c:\backup\projects.dat

    -You should now be at the point that I am which is that everything is working again, all your data is back. Yay!
    =-Good luck
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM

    Moving SharePoint Databases to a new SQL Server – Part 2

    Hi Ben
    Thanks for this article. I have this exact issue and Im trying to work thorugh it. Im having problems trying to figure out which GUID you used for the new SQL server. Its a little confusing with all the ParentID and ID fields in the DB. Do you remember how you foubnd the GUID for the new SQL server?

    Thanks
    John
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM

    Moving SharePoint Databases to a new SQL Server – Part 2

    I will continue to use SQL Lite, but thanks for the info.
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM

    Moving SharePoint Databases to a new SQL Server – Part 2

    I actually never got this working 100% before I got way too busy with some other projects.  I’m sure I’ll revisit this.  As far as having SharePoint on the SQL server, that isn’t a requirement.  The only thing you need on your DB server is SQL.  I also just saw this post on TechNet about moving all your databases.  It sounds like a much simpler approach but I’m not sure of its success or how well it works.

    http://technet.microsoft.com/en-us/library/cc512725(TechNet.10).aspx
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM

    Moving SharePoint Databases to a new SQL Server – Part 2

    I have a sharepoint farm with one server as Application and web srver and the other one as database. I need to move my sharepoint Database to a new server. Do we need to have SharePoint installed on the Server which I can use as a database server. If i see the comments posted in net im really confused if it didnt work out.
    Benjamin.SteginkNo presence information on 3/22/2011 12:21 AM