Friday, July 5, 2013

Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully

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 !!!





6 comments:

  1. I tried get-spdeletedsite, no resule.
    I ran Gradual Site Delete
    still doesnt work for me.
    other things I have tried:
    a, delete and recreate the web application.
    b, reset iis.

    Still error for me.

    ReplyDelete
    Replies
    1. get-spdeletedsite -webapplication http://sharepoint

      You need to run SPDeletedSite command against web application if that doesn't give any results, That means There is no deleted site collections from that web application.

      Try to check if the Content DB reached its site collection limit, storage capacity or read-only.

      Delete
    2. no problems with database
      but I found the issue. after I create the site collection. the site collection will be deleted in a few minutes. I have no idea which program did that.
      things I have tried:
      disabled timer job: dead site delete
      Gradual Site Delete

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Technology to store information like site configuration and content. SharePoint makes the data sharing easy and allows authorized users to access data over a wide network. Generally the data in SharePoint is saved in MDF format.

    Although, we are known to a fact that corruption in computer application is consistent. Similar is the case with Share Point Database, there are several error consequences which lead to corruption in SharePoint.

    In That See:- http://www.recoverydeletedfiles.com/sharepoint-server-data-recovery.html



    ReplyDelete
  4. Thanks, this worked for me.
    1. Remove the site collection permanently from database.
    Remove-SPDeletedSite –Identity

    2. Run the Gradual site delete timer job for immediate effect
    Central Admin > Monitoring > Review Timer Jobs > find "Gradual Site Delete" job for the web applications > Open the "Gradual Site Delete" job definition > click Run Now button.
    Then go to Job History and verify that the Gradual Site Delete job ran
    successfully.

    After doing this, I was able to restore my site collection from backup using the Restore-SPSite command.

    ReplyDelete