Friday, March 15, 2013

Deleting SharePoint Site Collections

A great post by Raymund Macaalay explains how you can re-organize your sharepoint sites and data by moving a SharePoint sub-site (SPSite) to a new site collection.  I used this method with great success to take an 80GB site collection and split some 10GB sub-sites out to their own site collections (and content databases).  During this process I had created numerous test site collections to verify the Import-SPWeb task would restore everything correctly.  Once done, I was happy to delete those site collections from the web application.

Since each of these site collections were around 10GB I was expecting a lot of free space to open up in the contentdb, which I would reclaim with a shrink operation.  However, the free space was not there.  This is because deleting a site collection from Central Administration does not permanently delete the site collection, it still exists in the second stage recycle bin which will store it for (default) 30 days.  To remove it from the contentdb immediately you need to run some PowerShell commands.

Get-SPDeletedSite will return a list of deleted sites:


You can permanently remove the sites by using the Remove-SPDeletedSite command:



Once this completes, you will still not see immediate relief in your contentdb.  This is because removing large amounts of content can be a resource intensive operation.  SharePoint has a Gradual Site Delete timer job that by default runs once daily and will gradually remove all content marked for deletion.  If you want to verify that your site is in the queue for the Gradual Site Delete job you can view the data in the dbo.SiteDeletion table of the content database.

After the site deletion job completes its work, you can use a shrink operation in SQL Server to reduce your contentdb to a desireable size.  If you have migrated sub-sites to other site collections like I did, don't forget to purge the original sub-sites from the second stage recycle bin which can be accessed from the Site Collection Administration section of the Site Settings page.

No comments:

Post a Comment