Sub topic 1
What you are backing up and why
This chapter defines what a Salesforce backup must contain and how to set recovery goals before you pick any export tool. Later chapters cover the tools themselves.
Prerequisites
This chapter assumes you have:
- Basic familiarity with Salesforce objects, records, and fields.
- Access to a Salesforce org (a sandbox or Developer Edition org is enough) with an administrator profile.
- Comfort reading CSV files and running commands in a terminal.
No commands are required in this chapter. The one query below is for orientation, and you can run it in the Developer Console if you want to.
Why Salesforce data still needs a backup
Salesforce runs the platform and keeps its infrastructure available. That does not protect you from the most common causes of data loss, which are mistakes made inside your own org:
- A user or admin mass-deletes or mass-updates records.
- A Data Loader or integration job overwrites good values with bad ones.
- A bad Flow or Apex trigger corrupts a field on many records.
- A deployment removes or changes a field, and its data goes with it.
- A deleted record stays in the Recycle Bin only for a limited time, and a hard delete skips the Recycle Bin.
A backup is a copy of your data and configuration, held outside the org, that you can use to get back to a known good state. Salesforce does offer recovery help for lost data, but it is a paid, slow, last-resort service. Treat it as a fallback and not as a plan.
Two things to back up: data and metadata
A Salesforce org has two parts, and you back them up in different ways.
- Data is the record content: accounts, contacts, opportunities, cases, attachments, and so on. You read it with queries and exports.
- Metadata is the configuration that defines the org: custom objects and fields, page layouts, Flows, Apex classes, validation rules, profiles, and permission sets. You read it with a manifest-based retrieve.
You need both for a full recovery. Data without metadata has nowhere to land, because the custom fields in your CSV files will not exist in an empty org. Metadata without data gives you a working but empty system.
| Aspect | Data | Metadata |
|---|---|---|
| Examples | Accounts, Contacts, Opportunities | Custom fields, Flows, Apex classes |
| Typical tools | Data Export Service, Data Loader, CLI, Bulk API | package.xml manifest, `sf project retrieve start` |
| Format | CSV or JSON | XML files in a project folder |
| Best storage | Encrypted file storage with retention rules | Version control such as Git |
| Change rate | Constantly | Occasionally, usually through deployments |
Because metadata changes rarely and arrives as text files, version control is a better home for it than a pile of dated archives. Data changes constantly and can be large and sensitive, so it needs encrypted storage and a retention policy. Those are different problems with different answers, which is why this tutorial treats them separately.
What to include in the data backup
Not every object deserves the same attention. Start by listing what the business cannot afford to lose, then decide how each group is backed up.
- Standard business objects. Account, Contact, Lead, Opportunity, Case, and their related objects such as Task and Event.
- Custom objects. Anything your team built. These often hold the most unique data, because nobody else has a copy.
- Files and attachments. Documents, ContentVersion records, and legacy Attachment records. These are the largest items and are often missed because they are not ordinary rows.
- History and audit data. Field history and similar tracking records, if you rely on them for compliance.
- Reference data. Users, record types, and similar records that other records point to. You need them to rebuild relationships later.
A short query shows how much data one object holds. Run it for your key objects to get a rough sense of scale.
SELECT COUNT() FROM AccountCounts like this help you size the work. They also become the baseline for checking completeness in the verification chapter.
What a backup does not capture well
Be explicit about the gaps, because they are where surprises happen.
- Some metadata types cannot be retrieved with a wildcard and must be named.
- System fields such as
CreatedDateandCreatedByIdare set by Salesforce on insert. A plain reload does not reproduce them unless you request special permission to set them. - Record Ids will change when you load records into a new org or re-insert deleted ones. Relationships must be rebuilt from the old Ids.
- Passwords and some security settings are not exportable.
- A file in a CSV export may be a link or a separate download, not the content itself.
Recovery goals: RPO and RTO
Two numbers guide every backup design.
- Recovery point objective (RPO) is how much data you can afford to lose, measured in time. An RPO of 24 hours means that after a failure you may lose up to a day of changes. It sets how often you must back up.
- Recovery time objective (RTO) is how long you can afford to be without the data. An RTO of 8 hours means the restore must finish within a working day. It sets how fast and how practiced your restore needs to be.
A weekly export gives an RPO of up to seven days. If sales staff enter fifty opportunities a day, that is a few hundred records at risk. You decide whether that is acceptable.
Set goals per data group, not for the whole org. Opportunities may need a daily backup, while a rarely changed reference object may need only a weekly one. Different goals lead to different tools and costs.
A worked example
Suppose a company has these needs.
| Group | What it holds | RPO | RTO | Likely approach |
|---|---|---|---|---|
| Sales data | Accounts, Contacts, Opportunities | 24 hours | 8 hours | Nightly scripted export |
| Support data | Cases, Case comments | 24 hours | 24 hours | Nightly scripted export |
| Files | Documents and attachments | 7 days | 3 days | Weekly full export |
| Configuration | Flows, Apex, custom fields | Each change | 8 hours | Retrieve into Git after deployments |
From this table you can already say which tools later chapters will matter most. Nightly scripts point to the CLI and automation. The weekly file export points to the scheduled Data Export Service. Metadata in Git points to the manifest approach. The recovery goals made these choices before any tool was opened.
Common mistakes
- Backing up only data. The restore then fails because custom fields and objects do not exist.
- Never testing a restore. An export that cannot be loaded back is not a backup. Later chapters cover rehearsal.
- Storing exports where anyone can read them. An export is a full copy of your customer data and carries the same risk as the org itself.
- Relying on the Recycle Bin. It is a short-term convenience, not a retention mechanism.
- Setting one goal for everything. This either overspends on low-value data or under-protects critical data.
- Keeping backups only in one place. If the same account holds the org credentials and the backups, one compromise loses both.
How this chapter connects to the rest
The next chapter compares the available export methods. Later chapters cover each one, plus verification, security, restore ordering, and the final backup plan. Each of those answers a question you can now state: what must be backed up, how often, and how quickly it must come back.
Exercise
A team exports all Account, Contact, and Opportunity records to CSV every night. They keep the files for a year. A developer later deploys a change that deletes a custom field, and the team needs to restore the org to its earlier state. What is missing from their backup, and what RPO does the nightly export give them?
Show answer
They have no metadata backup. The CSV files hold the data from the deleted field, but the field definition, along with Flows, Apex classes, layouts, and similar configuration, is not captured, so it must be retrieved separately with a package.xml manifest and ideally stored in version control. A nightly export gives an RPO of up to 24 hours, meaning up to a day of changes can be lost.
Exercise
Why should RPO and RTO be set for each data group and not once for the whole org?
Show answer
Different data has different business value and change rates. Critical, fast-changing data such as open opportunities may need a daily or more frequent backup and a fast restore, while rarely changed reference data can use a weekly backup. One org-wide goal either overspends on low-value data or leaves critical data under-protected.