The recycle bin feature in SharePoint 2010 comes handy when any accidental deletion occurs, you can easily move the items back, even your users can restore files from there. It is important to understand that a document’s life does not end when a user deletes it and this can affect the storage behind your SharePoint farm. Therefore the recycle bins during in planning phase are often misunderstood and underestimated (especially when you size storage and set up quotas).
By default SharePoint offers two recycle bins:
- first stage or end-user recycle bin
- second stage or site collection recycle bin
You can follow the possible transitions and connections between these two on the next figure.
Let’s start with a simple document deletion on a site. After this happens, the document disappears from the library and goes to the first stage recycle bin. From there the document can be restored or can go to the second stage place. If it stays in the first stage, after some time it will be completely purged and cannot be restored. From the second stage it can also be restored to the original place, or it can stay there until complete deletion.
Of course a few settings determine the behaviour of any document on this path, but the basic flow is as simple as this.
Stage one and quotas
I start from the bottom with the end user recycle bin. The most important thing to remember is that it belongs to a SITE. Every site has its OWN recycle bin.
To manage it simply click on the Recycle bin link on quick launch or type _layouts/recyclebin.aspx after your site’s URL.
In powershell use the RecycleBin property of an SPWeb object to retrieve all items in a site’s recycle bin. For example to check the bin of the previous screenshot use the following commands:
$site1 = Get-SPWeb “http://letitknow/sites/site1”
Every site has its own first stage bin and they are completely separate regardless any parent child relationships between them and are not merged on this level.
There is no specific limit on them, one can be 10MB and another can be 500MB if the following settings let them:
- the Delete items in the recycle bin (after specified days) among web application settings: an item cannot stay in the recycle bin (many days) longer as the days specified in this setting
- Any quota specified on a site collection
If any item in the bin is older than the days specified, the system deletes it.
And now let’s step back one level and take a glimpse from a site collection level.
Any site collection can have a quota template which specifies certain storage and sandboxed code limitations. For example the following screenshot shows a quota template on the Site1 site collection with 100MB storage space. This means that all content in this site collection must not exceed this value.
You might notice that the current storage used value is more than the specified limit so how can any site collection go over the limit? The reason is that during upload SharePoint only checks the current storage space is over the limit or not. If it is not, you can upload a document which might be bigger than the remaining space, hence your site collection will use more space than specified in quota template!
Please note you might experience problem when you try to restore an item under a site collection which is over the limit, it simply won’t let you to do it but also won’t say it in a nice way.
The error message tells you The item “” cannot be restored and for the reference presents a correlation ID. Searching in ULS logs gives you the following exception.
Microsoft.SharePoint.SPException: The item “” cannot be restored.
at Microsoft.SharePoint.SPRecycleBinUtility.ThrowAppropriateRestoreException(SPRecycleBinRestoreErrorData errorData)
at Microsoft.SharePoint.SPRecycleBinItemCollection.RestoreCore(Guid ids)
at Microsoft.SharePoint.ApplicationPages.RecycleBinPage.ProcessAction(String action, String guidString)
at Microsoft.SharePoint.ApplicationPages.RecycleBinPage.OnLoad(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Conclusion: check your site collection quota limits and currently used storage, because any restore operation fails if you are over the limit!
The most important thing to remember is that all site recycle bins (first stage) count toward this quota limit! Currently used storage can be calculated by adding all existing items under all sites and all items in your first stage recycle bins in all sites under a site collection. If this value is over your site collection quota settings you won’t be able to add more items. So if your users ask you for more storage space for their site collections check the site recycle bins first and see you can save some a couple of megs by emptying them.
There is a nice view about used storage under every site collection. On the top level site go to Site Settings -> Storage Metrics (under Site Collection Administration) or type /_layouts/storman.aspx after your top level site url.
One annoying problem with this page is that it lacks the information about the first stage recycle bins. It just does not take them into account! For example the following screenshot shows my recycle bin under Site1 and you won’t find any entry related to this on the previous screen. The same stands for any site under a site collection. This really makes it hard to track down why the storage under a site collection ran away…
Luckily there is a page which provides a nice overview about all items in all first stage recycle bins under a site collection. On the top level site go to Site Settings -> Recycle Bin (under Site Collection Administration) or type /_layouts/AdminRecycleBin.aspx after your top level site url. On this page you can check the size, original location, deletion date, etc for every individual item in there. From here you can restore or delete items. If you restore them they go back to their original location. If you delete them, they won’t appear under the site anymore and go straight to the second stage recycle bin (if it is not turned off).
Stage two and size configuration
And we arrived to the second stage. Items deleted from the end user recycle bin goes to the second stage by default, there are a few exceptions though: If it is turned off under web application general settings, all documents deleted from first stage will be purged forever, and you can only restore them from backup.
You can check the content of the second stage under Site Settings -> Recycle bin and clicking on the Deleted from end user recycle bin button on the left side.
Site collection admins have a restore option here as well in case of recovery. This space is site collection wide, there is only one per every site collection. It is important to understand that none of the items here count toward the site collection limit! If you are close to your limit, empty your first stage bins and even if they go to the second stage, voila you made some space in the site collection, you are not close to the quota anymore.
That presentation on the screenshot above with its 8MB size does not count towards the quota anymore. Second stage recycle bin size is specified on web application level under General settings in Central Administration.
It says that every site collection has a second stage recycle bin and the size must not exceed 50 percent of its quota. Site collections can have different quotas and therefore different second stage limits: 1000MB site collection will have a maximum of 500MB second stage size, or as another example a site collection with 100MB quota settings the second stage size is only 50MB. Keep this in mind when sizing your database, because this might hit back hard during operation! If you completely omit applying quota settings, second stage size can grow massive because there is no limit on it.
Please note that any item from first stage will skip the second stage if your second stage recycle bin specified storage space is less than the item’s size. For example my Quota size is 100MB, and second stage uses 50% settings, making it no more than 50MB. It is currently configured, but empty and a site admin tries to delete document from the first stage which has a size of 80MB. This document will simply skips the second stage and will be deleted permanently, and you will be unable to restore it from recycle bins anymore.
It’s not hard to guess that a timer job is responsible to empty your recycle bin. It has a very creative name: Recycle bin (you can find it under Monitoring -> Review job definitions)
- every web application has one. So if you have 5 web apps, you have 5 of this timer job
- it runs once every week, but you can reconfigure this
A timer job called Recycle Bin is responsible for purging old items from site and site collection bins. Every web application has its own, separate timer job for this task. By default these run once every week and based on the general settings of the web application (more specifically the Delete items in the Recycle Bin in days setting) remove old items from there, forever. There is no messing around with putting it to second stage from the first space, items will be purged from the first stage if their lifetime is over.
But don’t be surprised if your documents live longer there than the specified days. For example if your document was deleted on Monday, and your retention setting is 2 days at the moment, your document will remain there more than the specified 2 days, because the timer job will purge it only on Sunday!
Most important things to take away
- Every site has its own recycle bin
- Site recycle bins count towards site collection quota
- Every site collection has its own second stage recycle bin
- Second stage bins don’t count towards site collection quota
- Second stage recycle bin still consume additional storage space in your DB (additional to quotas)
- You can limit second stage bins among web application general settings with quota related percentage
- Item lifetime in recycle bin equals sum of time spent in first stage and time spent in second stage
- A timer job per web app (called Recycle Bin) is responsible for purge based on lifetime
- You cannot restore an item when your site collection size is over the allowed limit
- Any site collection can go over the limit. The reason is that during upload SharePoint only checks the current storage space is over the limit or not. If it is not, you can upload a document which might be bigger than the remaining space, hence your site collection will use more space than specified in quota template!
- If a deleted document does not fit in the second stage recycle bin, it skips that stage and SharePoint automatically deletes it. It happens if the size of the document is bigger than the specified second stage recycle bin storage space size.