Resources /
Blog

Salesforce Recycle Bin Retention: Recover Deleted Data

Submit your details to get a book

8
Min Read
Resources /
Blog

Salesforce Recycle Bin Retention: Recover Deleted Data

Download

Submit your details to get a book

8
Min Read
Clock counting down beside database and warning tiles, illustrating Salesforce Recycle Bin retention for deleted records
Clock counting down beside database and warning tiles, illustrating Salesforce Recycle Bin retention for deleted records

The Salesforce Recycle Bin keeps deleted records for a default retention period of 15 days, and users can restore them at any point in that window. After 15 days, Salesforce schedules the records for permanent deletion, as its Recycle Bin help page explains.

The Recycle Bin is a temporary safety net for accidental deletions, not a backup. Below, you'll find where it lives, how to bring deleted records back in Lightning, Classic or Apex, and what to do once they're gone.

What is the Salesforce Recycle Bin?

When a user deletes a record, Salesforce doesn't remove it right away. It flags the data as deleted and shows it in the Recycle Bin, a process Salesforce's large data volumes guide calls soft deletion.

Soft-deleted data still sits in the database, so queries have to filter it out. It can be recovered until the retention period runs out or someone empties the bin.

Each user has a personal Recycle Bin for the items they deleted. Admins can also access the Org Recycle Bin, which holds deleted data from every user.

How long do records stay in the Salesforce Recycle Bin?

Deleted records remain in the Recycle Bin for 15 days by default, in both Lightning Experience and Salesforce Classic. Salesforce then schedules them for permanent deletion, and says it "doesn't guarantee the exact time" of that deletion.

So don't plan around the last day. That window is the only guaranteed chance to recover deleted records from the bin.

Salesforce Support can enable Extended Recycle Bin Retention to stretch the window from 15 to 30 days. Records older than 15 days are only fully accessible in Salesforce Classic, though.

Does the Recycle Bin count against Salesforce storage?

Recycle Bin records don't count against your org's storage usage, according to Salesforce Help. It adds that there isn't a limit on the number of deleted items the bin can hold.

If you're tracking how much space you use, our guide to Salesforce storage limits covers data and file storage allocations.

Where is the Recycle Bin in Salesforce?

In Lightning Experience, open the App Launcher, then find and select Recycle Bin. You can also add it to your navigation bar, or add the Recycle Bin tab for your org in the Lightning App Builder.

In Salesforce Classic, the Recycle Bin link sits in the sidebar on the Home page. Use the View menu to switch between My Recycle Bin and All Recycle Bin, which shows deleted data across the entire org.

Who can view and restore deleted records?

What you see in the bin depends on your permissions, which is useful to know when you train your team on recovery. The table below lists the permissions Salesforce Help gives for each task.

TaskPermission needed
View and restore records you deletedRead on the records in the Recycle Bin
View and restore records other users deletedModify All Data
Restore deleted public tagsTag Manager
Permanently remove items or empty the org's Recycle BinModify All Data

How to restore deleted records in Salesforce

You can undo a deletion from the Lightning interface, from Classic, or with code. The right method depends on how much you need back and whether you know exactly which ones were deleted.

In Lightning Experience

  1. Open the Recycle Bin from the App Launcher.
  2. Choose your own Recycle Bin or the org's bin, then sort and filter the list view to find what you need.
  3. Select the items and click Restore.

Salesforce restores each item along with some of its relationships. For a step-by-step look at specific objects, see our guides to recovering deleted records and restoring deleted leads.

In Salesforce Classic

In Classic, search the Recycle Bin, select the checkbox next to each item, and click Undelete. To bring back everything you can see, select the checkbox in the column header first.

Searches match the field shown in the Name column, such as Lead Name or Case Number. Stemming and synonyms don't work in Recycle Bin search, so try the exact name.

With Apex or the API

For a large deletion, code is faster than clicking through list views. In Apex, the ALL ROWS keyword lets a SOQL query return deleted records, and the undelete statement brings them back.

Apex: restore deleted accounts
Account[] deletedAccts = [SELECT Id, Name FROM Account WHERE IsDeleted = true ALL ROWS];
undelete deletedAccts;

Through the SOAP API, queryAll() finds deleted records when you filter on isDeleted = true. You then pass their IDs to undelete(), which works on any record whose object is undeletable.

Some objects can't be restored at all. Salesforce's example is that Account records can be undeleted, but AccountTeamMember records can't.

To pull deleted data out without code, use the Data Loader and click Export All instead of Export. Data Loader then includes soft-deleted records in the CSV file, which shows what went missing before you undo anything.

What happens to related records when you restore?

Deleting some parent records also deletes their related records, so if an account is mistakenly deleted in Salesforce, its contacts go too. An undelete call brings those cascade-deleted records back.

Salesforce brings back many associations, including parent accounts, parent cases, Reports To managers and all custom lookup relationships. It only reconnects lookups that haven't been replaced in the meantime.

Merges are the exception. You can undelete a record removed by a merge, but its child records were reparented to the surviving record, and that can't be undone.

What happens after records are permanently deleted?

Once an item has been permanently deleted from the Recycle Bin, you can't recover it from Salesforce. Besides the retention timer, data is permanently deleted in three ways.

  • Someone empties the bin. A user with Modify All Data can empty their own Recycle Bin or click Empty Org Recycle Bin, and View Setup Audit Trail shows when the process finished.
  • Code empties it. The emptyRecycleBin() call deletes up to 200 records at once, and they can't be undeleted afterward.
  • A hard delete skips the bin entirely. Bulk API and Bulk API 2.0 offer this option, which bypasses the Recycle Bin.

After emptyRecycleBin(), queryAll() can still see the data for some time, usually about 24 hours, but you can't undelete it. Without a backup, each of these is permanent data loss.

When is the Recycle Bin not enough?

The bin covers one kind of mistake: a user who accidentally deletes records and notices before the retention window ends. Many causes of data loss in Salesforce fall outside it, such as bad imports, overwritten field values or a cleanup job that skips the bin.

  • No restore after the window, which is 15 days by default. If nobody checks the bin regularly and spots a deletion in time, the data is gone.
  • No record of changes. The bin only holds deleted records, so it can't undo an overwritten field value.
  • No long retention. Organizations with data retention policies may need data kept far longer than 15 days.

Salesforce's Data Export Service doesn't close the gap on its own. It runs weekly at most, and its zip files are deleted 48 hours after the email is sent.

That's why a real backup strategy sits behind the Recycle Bin rather than relying on it. Our Salesforce backup best practices and tips to prevent accidental data loss cover the rest.

The risk grows during large data migrations, where a problem may not show up until the Recycle Bin has already cleared what you'd need to roll back.

How Flosum Backup & Archive covers deleted data

Flosum Backup & Archive runs scheduled, incremental and high-frequency automated backups of Salesforce data and metadata. You can restore from a point in time at field, record or full-org level, so the Recycle Bin window stops being the deadline.

Flosum offers three deployment options: Salesforce-native, Flosum-hosted cloud and customer-hosted. Backup & Archive runs as a Flosum Cloud App, either Flosum-hosted on Flosum-managed AWS or customer-hosted on your own AWS, Azure or GCP.

In the Flosum-hosted setup, Backup & Archive can also write backups to your own S3 bucket or Azure Blob container, in your account and your region.

FAQs

How long do deleted records stay in the Salesforce Recycle Bin?

Deleted items stay in the Recycle Bin for 15 days by default, and users can restore them during that time. After that, Salesforce schedules them for permanent deletion, though it doesn't guarantee the exact time.

Where is the Recycle Bin in Salesforce Lightning?

Open the App Launcher, then find and select Recycle Bin. You can also add it to your navigation bar so it's one click away.

Can you extend Salesforce Recycle Bin retention?

Yes, but only to 30 days, and a System Administrator has to ask Salesforce Support to turn on Extended Recycle Bin Retention. Records older than 15 days are fully accessible only in Classic, so for anything longer you need a separate backup.

Can you recover records after they're permanently deleted?

Not from Salesforce. Once a record has been permanently deleted from the Recycle Bin, it can't be recovered, so you need your own backup to restore it.

Does the Salesforce Recycle Bin count against data storage?

No, Salesforce Help says records in the Recycle Bin don't count against your org's storage usage. It also says there isn't a limit on how many deleted records the bin can hold.

How do you query deleted records in Salesforce?

In Apex, add ALL ROWS to a SOQL query with IsDeleted = true. Through the SOAP API, use queryAll(), then pass the record IDs to undelete() to restore them.

Book a demo to see how Flosum Backup & Archive restores deleted Salesforce records long after the Recycle Bin has emptied.

Table Of Contents
Author
Stay Up-to-Date
Get flosum.com news in your inbox.

Thank you for subscribing

Ship Salesforce changes faster
Teams on Flosum report 40% higher development velocity and 75%
fewer merge conflicts.
Free to start  |  No credit card required