Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 36 ยท Data Management

Backup, Data Export and Recovery in Salesforce

Protect Salesforce data: the weekly Data Export Service, the Recycle Bin, field history and audit trail, Backup and Restore options, and a recovery plan, with JavaScript stand-ins.

Salesforce runs on resilient infrastructure, but it does not protect you from the most common data disaster: people. A mistaken mass update, a faulty import, a flow that blanks a field or a deleted account with ten years of history is your problem, not the platform's. Part of an administrator's job is to make sure that any change can be undone and that important data exists somewhere else. This lesson covers the built-in tools, their limits and a recovery plan.

Salesforce screens are described in words; the demonstrations are labelled JavaScript stand-ins. Nothing here shows real Salesforce output.

The Data Export Service

Setup, then Data Export lets you request a copy of your data as CSV files zipped for download. Two modes:

  • Export Now: available for a limited frequency (for example every 7 days in some editions, 29 days in others).
  • Schedule Export: weekly or monthly (the frequency depends on edition), at a chosen time.

Options: include images, documents and attachments, Salesforce Files and Salesforce CRM Content versions (these make the export much bigger), and all data with an option to Replace carriage returns with spaces (helps CSV parsing). When the export is ready, Salesforce emails you a link; the files stay available for 48 hours, after which they are deleted, so you must download them promptly. Files can be fetched by a script from the download links using the session (an admin must be logged in; the files are zipped in 512 MB or smaller pieces).

Limitations: the export contains data, not metadata (fields, flows, page layouts, permission sets), it cannot be restored with one click, and it is a snapshot of one moment. Treat it as a minimum safety net, and store the zip files somewhere secure and encrypted outside Salesforce, because they contain all your customer data.

The Recycle Bin

When someone deletes a record, it goes to the Recycle Bin for 15 days (or until the bin reaches its size limit, which is 25 times your storage megabytes' worth of records). Users can restore their own records (the Recycle Bin link in the App Launcher or the Deleted Items page), and admins can view the Org Recycle Bin and restore anyone's. Restoring brings back the record and its child records that were deleted along with it (for example, an account's contacts and opportunities), though some relationships and shares may need re-checking.

After 15 days, or after Empty Recycle Bin, records are gone from the UI. Admins can recover data within a short extra window by contacting Salesforce Support's data recovery service, which is paid and slow; do not rely on it.

A hard delete (the Data Loader's Hard Delete operation, or deleting from the bin) skips the bin. The Bulk API Hard Delete permission is not given by default; keep it limited.

History and audit

Several features track changes, which help you see what happened and repair it:

  • Field history tracking: for up to 20 fields per object, Salesforce records the old value, the new value, who changed it and when, kept for 18 months in the UI (24 months via API). Configure it per object (Object Manager, Fields and Relationships, Set History Tracking). History is only recorded from the moment you turn it on.
  • Field Audit Trail (paid add-on): up to 60 fields and retention for up to 10 years.
  • Setup Audit Trail (Setup, then View Setup Audit Trail): the last 180 days of setup changes, such as who edited a profile, flow or field, and a CSV download.
  • Login history and event monitoring for security questions.
  • Created By / Last Modified By and System Modstamp fields on every record.

These do not restore data on their own, but they tell you what the old value was, so you can fix records with a report and a mass update. A common recovery recipe: build a report on Opportunity Field History showing changes in the last hour, export it, and use the old values in an Update with the Data Loader.

Backup and Restore

Salesforce offers Backup and Restore (a paid product) that automatically backs up data and metadata and restores selected records or whole objects, including their relationships, to the same or another org. Third-party backup tools on the AppExchange offer similar features with granular restore and comparison. Which one you choose depends on your RPO (how much data you can afford to lose, in hours) and RTO (how fast you need to be running again).

A recovery plan

Write down, before disaster:

  1. What is critical? Accounts, contacts, opportunities, cases, custom objects, files.
  2. How often is it backed up, where is it stored, who can restore it?
  3. How do we restore a single record, one object, and the whole org?
  4. Who decides, and how do we tell the business?
  5. How do we test it? Practice a restore into a sandbox every few months. An untested backup is a hope, not a backup.
flowchart TD
  I["Incident: data lost or corrupted"] --> Q{"Deleted within 15 days?"}
  Q -->|"Yes"| RB["Restore from Recycle Bin"]
  Q -->|"No, values changed"| H["Use field history or audit trail to find old values"]
  H --> FIX["Update with Data Loader from a corrected CSV"]
  Q -->|"No, deleted long ago"| BK["Restore from backup (export zip or Backup and Restore)"]
  RB --> V["Verify counts and relationships"]
  FIX --> V
  BK --> V

Choosing a recovery path.

Stand-in: a Recycle Bin with a 15-day clock

This is a stand-in, not Salesforce. It models soft delete, restore and expiry.

JS Stand-in: soft delete, restore and expiry

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Stand-in: undo with field history

JS Stand-in: recover old values from history

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Practical rules

  • Export before big changes (mass updates, deletes, merges) and keep the file until the change is verified.
  • Limit powerful permissions: Modify All Data, Bulk API Hard Delete, Export Reports.
  • Turn on field history for the fields that matter most (Stage, Owner, Amount, Status) before you need it.
  • Practice restores in a sandbox. See Sandboxes and environments.
  • Store backups encrypted and with the same care as production data.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How long do deleted records stay in the Recycle Bin by default?

    Records stay in the Recycle Bin for 15 days (or until the size limit is reached).
  2. 2. How long are Data Export files available for download?

    Export files are removed after 48 hours, so download them promptly.
  3. 3. Which feature records old and new values of up to 20 fields per object?

    Field history tracking stores changes for a limited number of fields.
  4. 4. Does the Data Export Service include metadata such as flows and page layouts?

    The export is CSV data; metadata needs a separate backup (for example version control or a metadata backup tool).

Summary

  • Data Export gives a periodic CSV copy of your data (download within 48 hours); it contains data, not metadata.
  • The Recycle Bin restores deleted records for 15 days; hard deletes skip it.
  • Field history and Setup Audit Trail show what changed so you can repair data.
  • Write and test a recovery plan, and export before risky changes.

Next: Sandboxes and environments