I have an old production server that now serves as our Disaster Recovery server. I had been working on revamping our Disaster Recovery Strategy when, while performing a restore from production, it crashed in mid-restore.
I found that our SQL server that houses our Disaster Recovery SharePoint Databases had run out of disk space.
I cleared out a large amount of data from the server and tried the restore function again. The error persisted to come up again. This is when I discovered that the site had been orphaned when the restore process crashed due to lack of hard drive space.
The PowerShell script that I use for the restore is:
Restore-SPSite -Identity http://[YOUR URL]/ -Path b:\Backups\restore\[YOUR BACKUP FILENAME].bak -Force
Subsequent launches of the restore command in PowerShell gave me the following error.
Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection. Create another content database for the Web application and then try the operation again.
At line:1 char:15
+ Restore-SPSite <<<< -Identity http://[YOUR_URL]/ -Path b:\Backups\restore\[YOUR BACKUP FILENAME].bak –Force + CategoryInfo : InvalidData: (Microsoft.Share…dletRestoreSite: SPCmdletRestoreSite) [Restore-SPSite], InvalidOperationException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite
So, to clear this up, I ran the following scripts. This script is an stsadm command which will soon be phased out completely, but some of the commands still seem to work. As soon as I discover the comparable PowerShell commands, I will add them here as well.
On your SharePoint server, open a command prompt and navigate to c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Bin
Type the following command:
stsadm -o enumallwebs -databasename [content db] > output.xml 2>&1 (replace [content db] (do not use the brackets) with the name of your content database)
The above command placed a file called output.xml in the Bin Folder. Open the file that was generated above in notepad or your favorite text editor; analyze the file until you find the URL of the site collection that was deleted. Take note of the “site id” GUID – you will need this in the following step. In my case, there was an error finding the site and it listed the GUID for me. Your results may be slightly different.
Once you have obtained the GUID, type the following command at your command prompt in the same location as before:
stsadm -o deletesite -force -siteid [YOUR GUID] -databasename [YOUR DB NAME] -databaseserver [YOUR DB SERVER NAME] (Again, replace the bracketed data with your equivalent information.)
You should now be all set to run your restore procedure with no more difficulties.
Please feel free to comment or ask for clarification if needed. I hope you have found this information helpful.