Monday, April 7, 2014

Remove Site Collection and Reclaim Database Disk Space

Scenario
  • You need to remove a large site collection from your content database.
  • SharePoint 2010 or higher
Resolution
  • Use PowerShell after hours to remove the site collection:
     
    Remove-SPSite –Identity http://sitename
     
  • If you are on 2010 SP1 or later and if you used Central Admin or the SharePoint UI instead of the above PowerShell command or if you specified the -GradualDelete flag, then you must use PowerShell to remove the site collection from the recycle bin and then run the "Gradual Site Delete" timer job (or wait overnight for scheduled job), otherwise skip this step: 

    Get-SPDeletedSite -webapplication http://sitename | Remove-SPDeletedSite
     
  • Wait a few minutes for the database size to finish reducing (monitor via SQL Management Studio)
     
    Perform a FULL database backup on the content database (this will truncate the log files)
     
  • Then shrink the database via SQL command in SQL Management Studio:
     
    DBCC SHRINKDATABASE ('database_name' ,5 , NOTRUNCATE)
     
  • Then reorganize the indices (this should run automatically every day, but you can kick it off manually now):
     
    Run the following from Central Admin Health Analyzer (/Lists/HealthRules/AllItems.aspx) using Run Now:
     
    Databases used by SharePoint have fragmented indices

5 comments:

  1. That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
    Sharepoint Training in Chennai

    ReplyDelete
  2. Its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    Oracle Weblogic Server Training

    ReplyDelete
  3. Awe! What An Blog Very Helpful and interesting Really A great center for acquiring knowledge.Very Helpful Post And Explained Very Clearly About All the things.Very Helpful. Coming To Our Self We Provide Restaurant Equipment Parts .Really Thankfull For the blogger providing such a great information.Thank you. Have a Nice Day.

    ReplyDelete
  4. This Blog is very helpful and useful,came to know that i should be strong in my basics and this blog helps me to improve it,Urgent Care Services Provided by Us.Thanks For Posting.I Am refereed by my friend to this blog and i also want to refer my other friends to this blog.

    ReplyDelete
  5. I Just Love to read Your Articles Because they are very easy to understand US Medical Residency thanks for posting

    ReplyDelete