Sub topic 2
Choosing an export method
Salesforce gives you several ways to get records out of an org. They differ in what they can export, how much they can handle, whether they can run unattended, and who can use them. This chapter gives you a way to pick one, so the later chapters on each tool make sense in context.
This chapter assumes you know what Salesforce objects, records, and fields are. It also assumes you can read a CSV file and run commands in a terminal. A sandbox or Developer Edition org with an administrator profile is enough to follow along.
The five methods
- Data Export Service is a built-in Setup feature. It produces a set of CSV files for most of your objects, packaged in zip files you download. It can run on a schedule.
- Reports let a user export the rows of a report to a spreadsheet or CSV. They are meant for small, targeted extracts.
- Data Loader is a desktop client. You give it an object, a set of fields, and an optional SOQL filter. It writes a CSV.
- Salesforce CLI (the
sfcommand) runs SOQL queries from a terminal. Because it is a command, you can script it and run it from a scheduler. - Bulk API 2.0 is the REST interface for asynchronous query jobs. Data Loader and some tooling use bulk processing underneath. You can also call it directly with an HTTP client.
SOQL (Salesforce Object Query Language) is the query language behind Data Loader, the CLI, and the Bulk API. The Data Export Service and reports do not need it.
Comparing the methods
| Method | Scope | Needs SOQL | Can be scheduled | Best for |
|---|---|---|---|---|
| Data Export Service | Most objects in one run | No | Yes, inside Salesforce | A full, periodic copy of the org's data |
| Reports | One report's rows | No | Not for file export | Quick, small extracts for a person |
| Data Loader | One object per query | Yes | Command-line mode is possible, but it takes setup | Admin-driven exports with chosen fields and filters |
| Salesforce CLI | One query per command | Yes | Yes, from cron or CI | Repeatable, scripted exports |
| Bulk API 2.0 | One query per job | Yes | Yes, from your own code | Large objects and custom integrations |
Three questions separate the methods in practice.
Do you need everything, or a slice?
The Data Export Service is the only option here that covers most of the org without you listing objects. Every other method works one query at a time. If your goal is "a copy of everything, once a week", start with the Data Export Service. If your goal is "all Accounts changed since yesterday", you need a query-based method.
Do you need to choose fields and filters?
The Data Export Service gives you the standard set of files. You cannot filter rows or pick fields. With SOQL you control both. This query exports only the fields you name and only the records changed since a date, which is the basis for incremental exports:
SELECT Id, Name, Industry, OwnerId, CreatedDate, LastModifiedDate
FROM Account
WHERE LastModifiedDate >= 2026-01-01T00:00:00Z
ORDER BY LastModifiedDateNaming fields explicitly is deliberate. SOQL has no SELECT *. That forces you to decide what is in the backup, and it means a newly added field will not appear in an export until you add it to the query.
Does it have to run without a person?
Reports and manual Data Loader runs need someone at the keyboard. The Data Export Service runs itself, but only on its fixed schedule. The CLI and Bulk API fit into your own automation, such as a nightly job. Automation gets its own chapter later.
A decision flow
The diagram turns the questions above into a path. It simplifies. Real choices also depend on edition, permissions, and policy.
What each method cannot do
Every method has gaps. Knowing them early avoids a surprise during a restore.
- Data Export Service. It is not a point-in-time snapshot you can request at any moment. The schedule limits how often it runs, and there is a minimum wait between manual requests. Download links expire after a short time (48 hours), so something must fetch the files promptly.
- Reports. They export only what the report shows, within the running user's visibility and the report's row limits. A report is not a record of the object.
- Data Loader. Its CSV output is flat. It cannot export the results of a subquery, so child records need their own export.
- CLI. It runs a query per command, so you manage the list of objects yourself. Very large objects need the bulk path.
- All query methods. They respect the permissions of the user or integration account. A user without access to a field or record will export without it, and the export will look complete when it isn't. Use a dedicated integration user with the access you intend to back up.
Parent fields work in a flat query, but child records do not. The query below reads Account.Name from the parent and also asks for child Tasks:
SELECT Id, FirstName, LastName, Account.Name,
(SELECT Id, Subject FROM Tasks)
FROM Contact
LIMIT 100The Account.Name column fits in a CSV. The Tasks subquery does not. Flat CSV tools such as Data Loader cannot export subquery results, so export Tasks with their own query and keep the Id and parent Id columns so you can relate the files later.
Deleted and archived records
A standard query returns only records that are not deleted. Data Loader offers an Export All operation, and the Bulk API accepts the queryAll operation. Both also return deleted records still in the Recycle Bin and archived activities. If your backup must show what was deleted, plan for one of these. A later chapter covers this.
A first export with the CLI
If you have not tried any method yet, the CLI is the quickest to run. It assumes you have already authorized an org and given it an alias, here my-prod-alias:
sf data query \
--query "SELECT Id, Name, Industry FROM Account" \
--result-format csv \
--target-org my-prod-alias > accounts.csvThe shell redirect writes the CSV to accounts.csv. Open the file and check the header row and a few records. A count query tells you how many rows to expect, which becomes the heart of verification later:
SELECT COUNT() FROM AccountCommon mistakes
- Treating a report export as a backup. A report depends on its filters and the viewer's access.
- Exporting only the objects you remember. Custom objects and junction objects get forgotten. The Data Export Service avoids this because it covers the org by default.
- Running exports as a personal admin account. When that person leaves, the schedule and the stored credentials break. Use a named integration user.
- Forgetting that metadata is separate. Record exports do not include flows, Apex classes, or object definitions. That is the job of a manifest-based retrieve, covered in a later chapter.
Exercise
A team needs a nightly copy of Opportunities changed in the last day, written to a file by an unattended job, and the Opportunity object has millions of rows. Which method fits best, and why not the Data Export Service?
Show answer
The Salesforce CLI in a scheduled script or, because of the volume, a Bulk API 2.0 query job. Both accept a SOQL filter such as WHERE LastModifiedDate >= yesterday and run without a person. The Data Export Service cannot filter rows and runs only on its own fixed schedule, so it cannot produce a nightly incremental extract.
Exercise
You export Contacts with a query that includes a (SELECT Id, Subject FROM Tasks) subquery using Data Loader. What goes wrong, and what is the fix?
Show answer
Data Loader writes flat CSV and cannot export subquery results. Remove the subquery, export Contacts and Tasks with separate queries, and keep each record's Id and parent Id columns so the files can be related when you restore.