Tuesday, May 24, 2011

Virtual Machine with SharePoint web server restored: what's next?

Do you want to take a snapshot of the Virtual machine where your SharePoint web server resides? No problem.
Worried how easy you can restore the snapshot? The short answer- it might be smooth, it might be tough.
Let me share my story when it's tough. After the reading - probability that you will restore the SharePoint VM increases dramatically.
  After the VM snapshot restore of the SharePoint Front End (with restore of the related SharePont databases) -the ULS log shows the following error for owtimer.exe:
  System.NullReferenceException: Object reference not set to an instance of an object.    
 at Microsoft.SharePoint.Administration.SPDatabase.get_SqlSession()    
 at Microsoft.SharePoint.Administration.SPContentDatabase.GetWorkItems(SPWorkItemCollection workItems, UInt32& dwColCount, UInt32& dwRowCount, Object& varWorkItems)
Once I have tried to run the SharePoint Configuration wizard it failed on 4th step with the following error:
Exception: System.Security.SecurityException: Access denied.
   at Microsoft.SharePoint.Administration.SPPersistedObject.Update()
   at Microsoft.SharePoint.Administration.SPService.Update()
The errors on the database side showed some issue with service accounts. The tweaking their permissions to the database didn't resolve the issue.
     Then I have decided to disconnect from the current config database. The disconnect failed with the same error as before : Access denied
   Here is the victory steps to bring the SharePoint alive from VM snapshot restore:

1. Take the config database offline (thru SQL Managament studio)

2.  Run the SharePoint configuration wizard -> It will show that it can't connect to configuration database and asks if you want to disconnect - and you want to do it ->Yes

3. Take the config database online

4.Run the SharePoint configuration wizard -> attach the config database - select the same config db as before. The wizard will fail with error in the end (which is normal) - the error will :
    "An update conflict has occurred, and you must re-try this action"
5. Stop  Windows SharePoint Services Timer 

 6. Clear the SharePoint Config cache (Drive:\ProgramData\Microsoft\SharePoint\Config\GUID). 
The complete instruction how to clear sharepoint config cache is on "An update conflict has occurred, and you must re-try this action"

           The article is overloaded with microsteps. Here is the consice way to know how to clear the SharePoint Config cache:
             - locate the folder   Drive:\ProgramData\Microsoft\SharePoint\Config\GUID.
             - every folder with GUID is for every config db. 
              - Keep the folder and Cache.ini
             -  delete all other files inside the folders (or just move them somewhere else to keep the copy of the cache)
           -  to check that cache is fresh - change the Cache.ini and restart the Windows SharePoint Services Timer. The Cache. ini should be overridden and new files should be created under the GUID folder.

7. Start Windows SharePoint Services Timer 

8. Run SharePoint Configuration Wizard.

By this time it ran through without any errors at least for me )

Happy restoring!