Saturday, December 15, 2012

Fix “No content databases in the web application were available to store your site collection” error when user Restore-SPSite cmdlet

In this post I will describe one interesting side effect of SP1 for Sharepoint 2010. As you probably know with this service pack it became possible to restore deleted site collections. See e.g. this post for details: SharePoint 2010 SP1 - Site Recycle Bin. But there is also one interesting side effect related with Backup-SPSite/Restore-SPSite cmdlets, which allow to backup and restore site collections. Suppose that you want to test how these backup/restore commands will work in your case (I strongly recommend to test it in your particular case before to use in the production or even before to suggest it to customers. Event if it is document quite well, you may find interesting which will be unique for your case). You backed up site collection and restored it on the target web application. Everything went smoothly first time.You found some problems, tried to fix them, delete 1st restored site collection and try to restore site collection 2nd time (probably with “force” switch parameter) and this time you got 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.

It sounds very strange, because you are even not close to the limit of content database capacity. So what is the reason?

The reason is in internal processes which occur when you restore the site collection. When you deleted your site collection first time in Sharepoint 2010 with SP1 it is not really deleted. As I said above you still have possibility to restore it from recycle bin. And its id prevents you form further tries to restore the same site collection in the same web application. What to do then?

First of all check the list of deleted site collections using Get-SPDeletedSite cmdlet. It may give you something like this:

PS C:\temp> Get-SPDeletedSite

WebApplicationId   : 35513b1d-408f-4643-b5f2-b417aaa252f0
DatabaseId         : 2bd59a50-7a94-4869-88af-ae1988be18fc
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : fc5ff8c9-2012-4fd8-b801-9a0efb0e71cd
Path               : /test
DeletionTime       : 14.12.2012 12:49:18

It means that there is site collection with “/test” relative url, which you can still restore. It prevents you from restoring of your site collection 2nd time. We need to remove this site collection completely. It can be done by 2 steps. First step is to use Remove-SPDeletedSite cmdlet with guid which you got from Get-SPDeletedSite command above:

Remove-SPDeletedSite –Identity fc5ff8c9-2012-4fd8-b801-9a0efb0e71cd

After that Get-SPDeletedSite won't show this site collection, but Restore-SPSite will still give the same error. The second step: 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.


  1. Exactly what I needed. Thanks!

  2. Excellet work.. This worked for me...

  3. IT worked for me ... Thanks....:D

  4. Excellent work! Thank alot saved my time.

  5. I used 'Get-SPDeletedSite' cmdlet to get the list of deleted sites and it returned nothing. I'm still getting this error. Please help..

  6. Atharva,
    did you try to restart you server? May be it caches the results somehow. Otherwise it is hard to suggest something without knowing details about environment.