Is recycle bin a list? And can we query recycle bin to get items deleted from a list,if so how to do it? And also where is the recycle bin data actually stored, is it stored in the content db ?
2 Answers
No, Recyle bin is not a List like other document library and lists. Yes you can Query Recyle Bin item like SPWeb.GetRecycleBinItems Method
All files are internally stored in Content DB in Sharepoint. Once it is Deleted permanently from Sharepoint, they it will be deleted from Content DB.
No it is not a list, it's work on the same concept as we have in windows.
yes you can access it via powershell or other ways. here is powershell example.
# recycle bin's are tied to a site collection so we need a site collection object
$site = get-spsite http://www.yoururl.com
#we can see everything in the recycle bin like this:
$site.Recyclebin
#unfortunately, the above command dumps quite a lot to the screen.
#fortunately, we can pipe the output to other commands for filtering and cleanup.
#This command will return all the webs in the recyclebin
$site.Recyclebin | where {$_.itemtype -eq "web"}
#we can build on this by adding a sort statement,
#here I sort by dirname, which is the URL path the item would have been at before it was deleted
$site.Recyclebin | where {$_.itemtype -eq "web"} | sort dirname
# we can format the output into a nice list
$site.Recyclebin | where {$_.itemtype -eq "web"} | sort dirname | select title, itemtype, dirname, itemstate
#note that in the above listing, itemstate shows which recycle bin it's in (FirstStageRecyclebin = End user Recycle Bin Items, SecondStageRecycleBin = Deleted from end user Recycle Bin)
#here's one more application of filtering to show everything that's not a page nor a list item
$site.RecycleBin | where { $_.itemtype -ne "file" -and $_.itemtype -ne "ListItem" } | sort dirname | select title, itemtype, dirname
In SharePoint everything stored into the Content Database, So all deleted items stored into the Content DB until permanently deleted from recycle bin.
-
1Good answer. Please note that recycle bin has two levels, SPWeb and SPSite. Anyway, quering SPSite will return both. Commented Jun 19, 2014 at 20:40