Fix Orphan D


Sometimes back, I headed up with an issue while I was trying  to attach one content database in the new environment. There was one site collection containing the managed path and the restore operation was throwing the following error:
“The attach operation cannot continue because another object in this farm already contains the same ID. Each object in a farm must have a unique ID. In order to proceed with the attach operation you must assign a new ID to this database. To attach this database with a new ID, use the Mount-SPContentDatabase command with the -AssignNewDatabaseId parameter. Note that if this new database and an existing database contain the same site collections, attaching this database will likely result in orphaned site collections due to conflicts between the two databases.”

My guess was to make sure no existing similar url be presence in the new environment where I’m going to restore the operation. So, I did clean up the manage path, and even check other site collection url. However, the error persists. Moved forward to take care of the orphan records there and ran the step1. It displayed me what we had inside there.
Step1
                  $OrphanDB = Get-SPDatabase | Where {$_.Name -eq "SP_xxxxxxxxx_Test"}
                  Write $OrphanDB
                 
                  Id               : ec73eabf-d801-432b-9ab6-390883217b6a
                  Name             : SP_xxxxxxxxx_Test
                  WebApplication   : SPWebApplication Name=Sharexxxx-Test
                  Server           : Testspsql_sys
                  CurrentSiteCount : 1
                 
Next step was to dismount this content database. Executed the step2 and confirmed ‘Y’ in the PowerShell window.
                  Step2
                  Get-SPContentDatabase -Identity ' SP_xxxxxxxxx_Test ' | Dismount-SPContentDatabase




At step3, removed the content database to ensure no presence of it on the environment DB where it is going to be restore again.
                  Step3
                  $pcmsdb = Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseServer "Testsp_sys" -DatabaseName SP_xxxxxxxxx_Test
                  Remove-SPContentDatabase -Identity $pcmsdb -force


Now, while executed the attached the content database again, it worked. Sometimes it is necessary to go a step back and clean up your mess (because we do repeatedly the same process on weekly/bi weekly manner) before process to next level.
Hopes it may help you!

Comments

Popular posts from this blog

SharePoint Framework Reference Guide

How to fix Azure DevOps error MSB4126

SharePoint Admin Center