Export data from an org into one or more JSON files.
Description for data export tree
Specify a SOQL query, either directly at the command line or read from a file, to retrieve the data you want to export. The exported data is written to JSON files in sObject tree format, which is a collection of nested, parent-child records with a single root record. Use these JSON files to import data into an org with the “sf data import tree” command.
If your SOQL query references multiple objects, the command generates a single JSON file by default. You can specify the –plan flag to generate separate JSON files for each object and a plan definition file that aggregates them. You then specify just this plan definition file when you import the data into an org.
Override the api version used for api requests made by this command
‑‑flags‑dir
N/A
Type: Value
Import flag values from a directory.
‑‑json
N/A
Type: Boolean
Format output as json.
‑‑output‑dir
‑d
Type: Value
Directory in which to generate the JSON files; default is current directory.
‑‑plan
‑p
Type: Boolean
Generate multiple sObject tree files and a plan definition file for aggregated import.
‑‑prefix
‑x
Type: Value
Prefix of generated files.
‑‑query
‑q
Type: Value Required
SOQL query, or filepath of a file that contains the query, to retrieve records.
‑‑target‑org
‑o
Type: Value Required
Username or alias of the target org. Not required if the target-org configuration variable is already set.
Examples for data export tree
Export records retrieved with the specified SOQL query into a single JSON file in the current directory; the command uses your default org:
1sf data export tree --query "SELECT Id, Name, (SELECT Name, Address__c FROM Properties__r) FROM Broker__c"
Export data using a SOQL query in the “query.txt” file and generate JSON files for each object and a plan that aggregates them:
1sf data export tree --query query.txt --plan
Prepend “export-demo” before each generated file and generate the files in the “export-out” directory; run the command on the org with alias “my-scratch”:
1sf data export tree --query query.txt --plan --prefix export-demo --output-dir export-out --target-org my-scratch