Issues :
Deleted a site collection and try to restore the same site collection with the Restore-SPSite command in SharePoint you will get the below 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.
Root cause :
This is because even though you delete a site collection from CA. It will be deleted from the content database from front end. But logically that site collection still be there in database. This can be restored from Recycle bin but not able to do further migrations.
Please execute
Get-SPDeletedSite command from PowerShell it will list all the site collections deleted from CA like the below report :
WebApplicationId : 2f210dbb-f6bb-43d2-b730-9cb61222cbdb
DatabaseId : 213a1719-929b-420c-89f8-d03f52a06bc7
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId : 5ce0264c-1dad-4ffa-8360-8195i24dac69
Path : /teams/Test2
DeletionTime : 7/4/2013 6:30:36 AM
Solution :
Solution for this is just 2 steps :
1. Remove the site collection permanently from database.
2. Run the Gradual site delete timer job for immediate effect
Remove site collection permanently from datbase :
this can be achieved by simple PowerShell script
Remove-SPDeletedSite –Identity 5ce0264c-1dad-4ffa-8360-8195i24dac69
Run the Gradual site delete timer job for immediate effect :
After that Get-SPDeletedSite won't show this site collection, but
Restore-SPSite will still give the same error.
So , go to
Central
administration >
Monitoring >
Job definitions and run the “
Gradual Site
Delete” job for the web application where you are trying to restore the site
collection.
After that wait some time (depends on the size of your site
collection) and try to restore site collection again. This time it should work
without problems.
Thank you !!!