Bulk export records from an org into a file using a SOQL query. Uses Bulk API 2.0.
Description for data export bulk
You can use this command to export millions of records from an org, either to migrate data or to back it up.
Use a SOQL query to specify the fields of a standard or custom object that you want to export. Specify the SOQL query either at the command line with the –query flag or read it from a file with the –query-file flag; you can’t specify both flags. The –output-file flag is required, which means you can only write the records to a file, in either CSV or JSON format.
Bulk exports can take a while, depending on how many records are returned by the SOQL query. If the command times out, the command displays the job ID. To see the status and get the results of the job, run “sf data export resume” and pass the job ID to the –job-id flag.
Include records that have been soft-deleted due to a merge or delete. By default, deleted records are not returned.
‑‑api‑version
N/A
Type: Value
Override the api version used for api requests made by this command
‑‑column‑delimiter
N/A
Type: Value Valid Values:BACKQUOTE, CARET, COMMA, PIPE, SEMICOLON, TAB
Column delimiter to be used when writing CSV output. Default is COMMA.
‑‑flags‑dir
N/A
Type: Value
Import flag values from a directory.
‑‑json
N/A
Type: Boolean
Format output as json.
‑‑line‑ending
N/A
Type: Value Valid Values:LF, CRLF
Line ending to be used when writing CSV output. Default value on Windows is is CRLF; on macOS and Linux it’s LR.
‑‑output‑file
N/A
Type: Value Required
File where records are written.
‑‑query
‑q
Type: Value
SOQL query to execute.
‑‑query‑file
N/A
Type: Value
File that contains the SOQL query.
‑‑result‑format
‑r
Type: Value Required Valid Values:csv, json Default value:csv
Format to write the results.
‑‑target‑org
‑o
Type: Value Required
Username or alias of the target org. Not required if the target-org configuration variable is already set.
‑‑wait
‑w
Type: Value
Time to wait for the command to finish, in minutes.
Examples for data export bulk
Export the Id, Name, and Account.Name fields of the Contact object into a CSV-formatted file; if the export doesn’t complete in 10 minutes, the command ends and displays a job ID. Use the org with alias “my-scratch”:
1sf data export bulk --query "SELECT Id, Name, Account.Name FROM Contact" --output-file export-accounts.csv --wait 10 --target-org my-scratch
Similar to previous example, but use the default org, export the records into a JSON-formatted file, and include records that have been soft deleted:
1sf data export bulk --query "SELECT Id, Name, Account.Name FROM Contact" --output-file export-accounts.json --result-format json --wait 10 --all-rows