Resources /
Blog

How to Prevent Accidental Data Loss in Salesforce

Submit your details to get a book

8
Min Read
Resources /
Blog

How to Prevent Accidental Data Loss in Salesforce

Download

Submit your details to get a book

8
Min Read
Accidental data loss: a shield with a lock on a hexagon platform, linked to database, clock, copy and warning tiles
Accidental data loss: a shield with a lock on a hexagon platform, linked to database, clock, copy and warning tiles

You prevent accidental data loss in Salesforce by limiting who can delete or mass-edit records, validating data before it saves and testing changes in a sandbox. Then deploy through a reviewed pipeline, and keep tested backups of data and metadata outside the org.

The Recycle Bin is only a short safety net. Deleted records stay there for 15 days by default, and a Bulk API hard delete skips it entirely.

Which mistakes cause data loss in Salesforce?

Most incidents start with human error by someone who has the access to make a change. Salesforce's Backup & Recover training puts it plainly: "Users with appropriate permissions can inadvertently delete or modify critical data."

The same unit lists failed integrations, bugs in custom code or third-party applications, and imports that fail partway through. Our post on the common causes of data loss in Salesforce covers each one, so this guide sticks to the controls that stop them.

The table below pairs the accidental scenarios from Salesforce's list, plus destructive deployments, with the control that prevents each one. Each control has its own step further down.

CauseWhat goes wrongControl that prevents it
Accidental deletion or modificationA user with delete or edit rights removes or overwrites the wrong recordsLeast-privilege permissions, with hard delete turned off
Data corruption during importsA large import fails partway and leaves data in an inconsistent stateValidation rules, a sandbox test load and a backup first
Application errorsBugs in custom code, apps or automation change data unexpectedlySandbox testing and reviewed deployments
Destructive deploymentsA deployment deletes components, and purgeOnDelete skips the Recycle BinA review of every destructive change before it ships

Why do accidental deletions matter for compliance?

Under the GDPR, a personal data breach is "a breach of security leading to the accidental or unlawful destruction, loss, alteration, unauthorised disclosure of, or access to, personal data transmitted, stored or otherwise processed." Accidental loss sits in that definition right beside unlawful destruction.

Article 32 also asks for "the ability to restore the availability and access to personal data in a timely manner in the event of a physical or technical incident." Our GDPR compliance guide covers how Article 32 applies to Salesforce backups.

How do you prevent accidental data loss in Salesforce?

These seven steps work as layers, so a mistake that slips past one gets caught by the next. The first four stop errors from happening, and the last three limit the damage when one gets through.

For controls against every cause of Salesforce data loss, including integration failures and malicious activity, see how to prevent Salesforce data loss. The steps below stick to the mistakes people make inside the org.

1. Limit who can delete and mass-edit records

Object permissions decide whether users can create, read, edit or delete records of each object. Salesforce recommends setting them with permission sets and permission set groups, and using profiles for default settings such as apps and page layouts.

Salesforce's data security best practices say least privilege "helps ensure that users only have access to the data they need for their roles." Our guide to Salesforce permission sets shows how to build them by task.

Three permissions need their own review:

  • Delete on each object, which should go only to roles that remove records as part of the job.
  • View All Data and Modify All Data, which override all other sharing settings and belong on the System Administrator profile unless there's a documented reason.
  • Bulk API Hard Delete, which lets records skip the Recycle Bin and stays disabled until an administrator turns it on.

Review these assignments on a schedule, because access tends to grow as people change roles. That drift is how permission sprawl builds up, and it applies to integration users as much as to employees.

2. Stop bad data at entry with validation rules

Validation rules "verify that data entered by users in records meets the standards you specify before they can save it." A rule evaluates a formula, and when the result is True, the record has an invalid value and the user sees your error message.

Put rules on the fields that other records and automations depend on, such as a status, an amount or an external ID. A record that never saves with a bad value is one less record to repair after a mistake.

3. Know what the Recycle Bin can and can't restore

When a user deletes a record, Salesforce flags it as deleted instead of removing it, a process it calls soft deletion. Deleted items stay in the Recycle Bin for 15 days by default, and they can be restored during that time.

Once the retention window passes, they're scheduled for hard deletion, and Salesforce doesn't guarantee exactly when that happens. The bin can also be emptied by hand through the UI, the API or Apex, as our post on Recycle Bin retention explains.

Some deletions never reach the bin at all. A Metadata API deployment with purgeOnDelete set to true bypasses it, and so does a Bulk API hard delete.

A roll-up summary field deleted through Metadata API is purged even without that option. Our guide to recovering deleted records in Salesforce covers the restore steps for everything that does land in the bin.

4. Test changes and data loads in a sandbox

Salesforce's sandbox guide says: "By isolating changes in a sandbox, you reduce the chance of errors reaching your live apps." It also warns that even a simple layout change can clash with other customizations when nobody tests it.

Pick the sandbox to match the job. Developer and Developer Pro sandboxes refresh once per day, Partial Copy every 5 days and Full Copy every 29 days, as our sandbox types guide explains.

Rehearse data loads and new integrations in a Partial Copy or Full Copy sandbox with realistic records before they touch production. Salesforce suggests masking so those environments hold realistic but non-sensitive data, and our data masking post shows how.

5. Deploy through review, not by hand

A deployment can delete components as well as add them. Metadata API removes whatever is listed in a destructiveChanges.xml manifest, so one wrong line in that file takes a component out of the org.

Manual change sets bring their own risks, from missed dependencies to the limits our post lists. A Salesforce deployment process with version control, peer review and approval gives every change an owner and a way back.

Write the approval rules down in a data governance policy that says who signs off on which changes. Then back up data and metadata before any large release or data migration, so you have a known good state to return to.

6. Back up data and metadata outside the org

Salesforce's own Data Export Service runs every 7 or 29 days, and weekly exports are only available in Enterprise, Performance and Unlimited Editions. Its zip files are deleted 48 hours after the email is sent, so someone has to download each one.

Salesforce also offers a Backup & Recover solution, and third-party tools are another option. Whichever you choose, keep at least one copy outside the production org and cover metadata, files and attachments as well as records.

Set RPO and RTO targets for how much data you can afford to lose and how fast it has to come back. Those targets belong in your disaster recovery plan, which our guide to planning Salesforce backup and recovery walks through.

A backup only counts once you've restored from it. Salesforce's best practices say: "Regularly testing your backups ensures they can be restored successfully during data loss."

Our Salesforce backup best practices cover schedules, scope and restore tests. The 3-2-1 backup rule explains how many copies to keep and where.

7. Monitor changes and review them

Setup Audit Trail records the changes admins make in Setup for at least the last 180 days. Deployments are logged too: the MetadataApiOpEventLog object "stores details of Metadata API retrieval and deployment requests."

Check those logs against your release calendar each week, and look into any permission change or deployment nobody planned. Our audit trail compliance guide covers keeping that history past the 180-day window.

How does Flosum help prevent data loss?

Flosum DevOps runs in Flosum's cloud or in your own cloud. Flosum's DevOps Cloud App runs every change through version control, approvals and an audit trail.

It also captures each deployment so it can be reversed in one click, with impact analysis. A bad release gets rolled back before it does more damage.

Backup & Archive is a Flosum Cloud App, so its backups run outside your org. Flosum Backup & Archive runs scheduled, incremental and high-frequency backups of data, metadata, files and attachments, independent of Salesforce's own infrastructure.

You can restore to field, record or full-org level from a point in time. Flosum Backup & Archive runs in Flosum's cloud or in your own cloud.

FAQs

What is accidental data loss?

It's data that's deleted, overwritten or corrupted by mistake, such as through a wrong mass update, a failed import or a deployment that removes a field. Salesforce's Trailhead names accidental deletion or modification first among common data loss scenarios.

How long does Salesforce keep deleted records?

Records you delete sit in the Recycle Bin for 15 days by default, and you can restore them in that window. A Bulk API hard delete bypasses the bin, so those records can't come back from it.

Is accidental deletion of personal data a data breach under the GDPR?

It can be, because the GDPR defines a personal data breach to include accidental destruction, loss or alteration of personal data. A mass deletion of customer records needs the same assessment as a security incident.

Does Salesforce back up my data?

Salesforce gives you the Data Export Service, which produces export files every 7 or 29 days, and also offers a Backup & Recover solution. An export file nobody has restored from won't prove much, so pick a backup you can restore and test it.

Who should have the Modify All Data permission?

As few people as possible, because it overrides sharing settings across the org. Salesforce's object access unit advises caution before adding it to any profile other than System Administrator.

How do you stop a deployment from deleting data by mistake?

Review every destructiveChanges.xml manifest before it ships, and leave purgeOnDelete off so deleted components go to the Recycle Bin. Back up data and metadata first, too, since roll-up summary fields are purged even with that option off.

Book a demo to see how Flosum Backup & Archive protects your Salesforce data and metadata from accidental loss.

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

Thank you for subscribing

Ship Salesforce changes faster
See how City and County of Denver cut routine deployments from up to 2 days to under 15 minutes.
Free to start  |  No credit card required