locked
Huge Recycle Bin RRS feed

  • Question

  • I have a client with an enormous SP2007 Recycle Bin. Second Stage is at almost 1.5 Million items. Almost all of the items are workflow history List items, but I'm not having any luck cleaning it with the GUI (error), STSADM (also error), or Powershell (slow as mud and deadlocks the DB). I'm to the point where I think they would be better served to just shut off recycle bins for the webapp and re-enable them with more stringent policy going-forward.

    My question is, has anyone done this or do you have any recommendations regarding the issue I'm facing? If I have a service window of 3 days to do it, does the disable/enable of the recycle bins on the webapp have time enough to complete?

     

    Thanks for any opinions and thoughts on the matter,

     

    --Andrew

    Tuesday, September 20, 2011 4:42 PM

Answers

  • Hi Andrew,

     

    I agree with Zoeb and Rashu’s  opinions.

     

    Below sample code will delete items from second-stage (Admin) recycle bin and also has option to put a rowlimit on the number of records that need to be deleted at a time.

     

    It can be included in a console application, just need to replace the Main() method with below code and compile to get the executable.

     

    <Sample-Code>

     

      static void Main(string[] args)

            {

                try

                {

                    Console.WriteLine("Please specify the Site Collection Url: (Please click enter after typing)");

                    string strUrl = Console.ReadLine();

                    SPSite site = new SPSite(strUrl);

               

                    SPWeb web = site.RootWeb;

     

                    SPRecycleBinQuery q = new SPRecycleBinQuery();

     

                    Console.WriteLine("Specify the number of records to be deleted (Click enter after typing)");

                    q.RowLimit = Int32.Parse(Console.ReadLine());

                    q.OrderBy = SPRecycleBinOrderBy.Default;

                    q.ItemState = SPRecycleBinItemState.SecondStageRecycleBin;

     

                    SPRecycleBinItemCollection itemColl = site.GetRecycleBinItems(q);

                    foreach (SPRecycleBinItem item in itemColl)

                    {

                        Guid[] id = new Guid[1];

                            id[0] = item.ID;

                            itemColl.Delete(id);

     

                       

                    }

                    Console.WriteLine("Deletion was successful (Click enter to exit)");

                    Console.ReadLine();

                   

                }

                    catch (Exception ex)

                    {

                    Console.WriteLine("Exception Message" + ex.Message);

                    }

     

            }

    </Sample-Code>

     

    For more information about delete objects from the second stage recycle bin, see the following articles:

     

    http://blogs.msdn.com/b/ajithas/archive/2009/09/08/deleting-very-large-objects-from-the-second-stage-recycle-bin.aspx

     

    http://www.directsharepoint.com/2011/05/how-to-delete-all-items-from-site.html

     

    Thanks,

    Rock Wang

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Regards, Rock Wang Microsoft Online Community Support
    Thursday, September 22, 2011 2:48 AM

All replies

  • Hi Andrew,

    We also have the similar issue in our environment, what i usually do is. If the Storage space allocated to the site is 3 GB , i increase the Storage space of the site to 10-12 GB, i.e. 3 to 4 times bigger and try deleting the Items from the recycle bin. That does the trick.

    IF the above doesn't solve your issue. Please let us know the Error you are getting from STSADM and from GUI .

     


    Thanks & Regards Posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, September 20, 2011 6:13 PM
  • Hi,

    What is the error message you are getting?

    Are you selecting all items and trying to delete ?

    If yes then select few initially and then delete and keeps on increasing the number.

    I hope this will help you out.


    Thanks, Rahul Rashu
    Wednesday, September 21, 2011 3:53 AM
  • Hi Andrew,

     

    I agree with Zoeb and Rashu’s  opinions.

     

    Below sample code will delete items from second-stage (Admin) recycle bin and also has option to put a rowlimit on the number of records that need to be deleted at a time.

     

    It can be included in a console application, just need to replace the Main() method with below code and compile to get the executable.

     

    <Sample-Code>

     

      static void Main(string[] args)

            {

                try

                {

                    Console.WriteLine("Please specify the Site Collection Url: (Please click enter after typing)");

                    string strUrl = Console.ReadLine();

                    SPSite site = new SPSite(strUrl);

               

                    SPWeb web = site.RootWeb;

     

                    SPRecycleBinQuery q = new SPRecycleBinQuery();

     

                    Console.WriteLine("Specify the number of records to be deleted (Click enter after typing)");

                    q.RowLimit = Int32.Parse(Console.ReadLine());

                    q.OrderBy = SPRecycleBinOrderBy.Default;

                    q.ItemState = SPRecycleBinItemState.SecondStageRecycleBin;

     

                    SPRecycleBinItemCollection itemColl = site.GetRecycleBinItems(q);

                    foreach (SPRecycleBinItem item in itemColl)

                    {

                        Guid[] id = new Guid[1];

                            id[0] = item.ID;

                            itemColl.Delete(id);

     

                       

                    }

                    Console.WriteLine("Deletion was successful (Click enter to exit)");

                    Console.ReadLine();

                   

                }

                    catch (Exception ex)

                    {

                    Console.WriteLine("Exception Message" + ex.Message);

                    }

     

            }

    </Sample-Code>

     

    For more information about delete objects from the second stage recycle bin, see the following articles:

     

    http://blogs.msdn.com/b/ajithas/archive/2009/09/08/deleting-very-large-objects-from-the-second-stage-recycle-bin.aspx

     

    http://www.directsharepoint.com/2011/05/how-to-delete-all-items-from-site.html

     

    Thanks,

    Rock Wang

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Regards, Rock Wang Microsoft Online Community Support
    Thursday, September 22, 2011 2:48 AM
  • Hi,

    Did you resolve your issue, if you have any questions, feel free to let me know.

    Rock Wang

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Regards, Rock Wang Microsoft Online Community Support
    Thursday, September 29, 2011 7:44 AM