Recently I was carrying out a cumulative update release on a client SharePoint farm, when running the Test-SPContentDatabase commandlet I was faced with an orphaned site which could cause upgrade failures.
If you have orphaned sites in your content databases, get these cleaned up and tested in another environment before starting your production upgrade or it could be a very stressful time when sites within that content database will not load!
Test each content database before the upgrade:
Test-SPContentDatabase -Name ContentDB_Matt -WebApplication https://matt.test.com
In my case I was seeing the below errors for one database in particluar.
Category: SiteOrphan
Error: True
UpgradeBlocking: False
Message: Database [ContentDB_Matt] contains a site (Id = [********************], Url = [matt.test.com]) that is not found in the site map. Consider detach and reattach the database which contains the orphaned sites.
Restart upgrade if neccesary.
Category: SiteOrphan
Error: True
UpgradeBlocking: False
Message: Database [ContentDB_Matt] contains a site (Id = [*********************], Url = [matt.test.com]) whose url is already used by a diferent site, in database (Id = [***********************], name = [ContentDB_Matt], in the same web application. Consider deleting one of the sites which have conflicting urls.
Remedy: The orphaned sites could cause upgrade failures. Try detach and reattach the database whcih contains the orphaned sites.
Restart upgrade if neccesary.
You will need to use the id in the above error message, and do a Get-SPSite for the web application. If a site with the above ID is not returned via PowerShell then this orphaned site needs to be deleted.
Be carefull to check that the site ID in the error is not retuned in the Get-SPSite commands or you will be deleting a current site by mistake, take extra time to validate the site IDs before running any delete.
Using a non-production environment will give you a safety net here.
Using trusty old stsadm, enumerate all the sites in the content database to get a full list or sites and their subsites.
stsadm -o enumallwebs -database ContentDB_Matt
If you have orphaned sites you will see a mismatch in the number returned by enumallwebs and the number returned using Get-SPSite in PowerShell.
Get-SPSite -ContentDatabase "ContentDB_Matt" | select ID
Once you have compared the site IDs of those returned by enumallwebs and Get-SPSite you will have the IDs of the orphaned sites to be deleted.
Again stsadm comes to the rescue here, as within PowerShell I could not find the orphaned sites by ID.
stsadm -o deletesite -force -SiteID ********************* -DatabaseName ContentDB_Matt -DatabaseServer Matt_SQL_Instance
Run enumallwebs after the delete and that orphaned site should now be gone, and once all orphaned sites are deleted running enumallwebs and Get-SPSite should return a matching number of sites!
stsadm -o enumallwebs -database ContentDB_Matt
Get-SPSite -ContentDatabase "ContentDB_Matt" | select ID
Now when you run Test-SPContentDatabase it should not return errors about orphaned sites.
Good luck with your upgrades.
Matt
Thanks Matt! This info came in handy tonight to help me get rid of an orphan site. Keep up the great posts!
ReplyDelete