SharePoint – why is nothing ever quick ? Recently I had to help out a client who was trying to restore a single piece of content from a backup. We had a backup copy of the content-db and the client also had a recovery farm we could use, so this shouldn’t have taken long. The backup was over 200 GB, so the 1st problem was to find enough space on the DR farm to recover the content db, once we had enough space the backup was restored to SQL and we attached the content db to the recovery farm, but the Current Number of Sites, was 0, very odd…
I ran a couple of SQL queries on the content db to get some information about its content, but SharePoint refused to show me any content, so we detached and reattached, moved to another Web-app and reattached but nothing appeared, and no errors were reported from the UI. I took a look a the ULS logs, which was showing nothing, just the headings. An IIS reset and restart of the Tracing service kicked the ULS logs into action and we tried the reattach again, now we were getting errors in the ULS log.
The site named <Site Collection Name> and with id bc229270-86b6-4606-832e-a38c0e71058d was found in the content database <database name> in the database server <SQL Server Name>. However, the following error was reported while adding a mapping to this site to the configuration database. Operation is not valid due to the current state of the object.
System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint ‘PK_SiteMap’. Cannot insert duplicate key in object ‘dbo.SiteMap’. The statement has been terminated
This DR farm had all sorts of other Web Apps and content db’s attached, but I finally worked that another copy of the same db with a different name as attached to one of the other Web Apps, once that was detached we could attach our db, find the site, get the content out and make the client and end user happy
Another day in the wonderful world of SharePoint !