Wednesday 9 November 2011

SharePoint 2007 - Orphan Sites


 

I was working with alongside one of the guy's from Microsoft the other day and we were implementing the MS IT Site Delete Capture Utility available from Codeplex. Part of the testing required me to create/delete & restore sites. Briefly, the site delete capture utility intercepts both site/web delete requests and archives the site/web. Having deleted the site from within Site Settings of the site. I then attempted to restore the site using STSADM at which point I was presented with an message telling me that the site collection already existed and that I should use another name. Ive just deleted it so that cant be right, so i immediately navigate to Central Administration and surprisingly the offending site is still there. I then try to delete the site from within Central Administration page but again it would not delete. Finally, I try to delete the site with STSADM but I got this error with stsadm.exe -o deletesite: The system cannot find the path specified. (Exception from HRESULT: 0x80040E2F). Not sure at this point if this is as a result of implementing the site delete feature, I look at the Event logs, ULS and the log that is provided with the site delete feature. Nothing indicated that the site delete feature was at fault.
A quick search and I learn of a term called "Orphan Sites". As it happens, orphan sites are not that uncommon and Microsoft had previously worked on a fix. It seems however that in some cases this issue can still occur but what Microsoft have done is provide some pretty cool STSADM operators to help resolve it, if it does occur.

An Orphaned Site is where SharePoint only has partial information and not a complete set of data for a given site collection in your Windows SharePoint Services or SharePoint Portal Server content databases or configuration databases. The site may in fact still be viewable via the browser, but you may notice that many things are broken.

An orphaned site may manifest itself in one of the following:

  • STSADM -o restore fails to restore the site, even with the -overwrite option when you know the URL exists.
  • You may receive an error code 0x80040E2F. 0x80040E2F means “Violation of PRIMARY KEY constraint”, this equates to STSADM already finding previous rows in the database for the items it's trying to restore.

    NOTE: STSADM first looks at the Configration and Content Databases to ensure that the site does not already exist, if it does and you didn't use the -overwrite switch, it will fail. If STSADM does not find any information, it begins restoring which then results in the problem noted above.
  • STSADM -o deletesite fails to delete the site
  • You may receive and error which states "The site does not exist". Again, No site information in Configuration or Content database in their respective Sites tables. Thus the other remnants of the site cannot be cleaned up.

To resolve this issue you must carry our the following 2 actions:

STEP 1

  1. Open a command prompt and go to change directory to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN and type the following:

    stsadm -o databaserepair -url http://Web/sites/Site -databasename <DatabaseName> (This will list all sites that are orphaned)
  2. Next, type the following:

    stsadm -o databaserepair -url http://Web/sites/Site -databasename <DatabaseName> -deletecorruption
  3. You will then be presented with a result in xml format with a deleted attribute that equals to YES

    <OrphanedObjects Count="22"><Orphan Type="SPSite" Id="{E732BEEC-F4BD-40D7-A51F-7B33BA7D5698}" Deleted="Yes" />

STEP 2
  1. Launch SharePoint Central Administration.
  2. Select Application Management and under SharePoint Web Application Management select Content Databases
  3. Select the Content Database where the offending site remains.
  4. Make a note of the following settings:

    • The name of the Content Database.
    • The number of sites before a warning is sent.
    • The maximum number of sites setting.
    • The Windows SharePoint Services Search Server.
  5. Click to select the Remove content database check box, and then click OK. When you are prompted to confirm that you want to remove the content database, click OK.
  6. Click OK.
  7. On the Manage Content Databases page click Add a content database.
  8. On the Add a Content Database page, specify the database server, the database name, and the database capacity settings. Then, click OK.
  9. Once you have dont that, select the Content Database you have just re-added and ensure you select the Windows SharePoint Services Search Server noted earlier.
Having done that you should now be able to restore/recreate a site with the old name.

For further reading try the following Sharepoint Orphans Explained

No comments:

Post a Comment