hardis:org:data:export
Description
Command Behavior
Exports data from a Salesforce org using an SFDMU (Salesforce Data Migration Utility) project.
This command facilitates the extraction of data from your Salesforce environments based on configurations defined in an SFDMU workspace. It's a powerful tool for various data-related tasks, including:
- Data Backup: Creating snapshots of your Salesforce data.
- Data Migration: Extracting data for transfer to another Salesforce org or external system.
- Reporting and Analysis: Exporting specific datasets for detailed analysis outside of Salesforce.
- Data Seeding: Preparing data for import into other environments.
Key functionalities:
- SFDMU Workspace Integration: Leverages an existing SFDMU workspace (defined by an
export.jsonfile) to determine which objects and records to export, along with any filtering or transformation rules. - Interactive Workspace Selection: If the SFDMU workspace path is not provided via the
--pathflag, it interactively prompts the user to select one. - Org Selection: Ensures that a target Salesforce org is selected (either via the
--target-orgflag or through an interactive prompt) to specify the source of the data export. - Confirmation Before Exporting: Displays a summary of the objects handled by the workspace (object, operation, external id, filter, mocked fields) followed by the full
export.json, then asks for confirmation before querying the org.
See this article for a practical example:
Technical explanations
The command's technical implementation relies heavily on the SFDMU plugin:
- SFDMU Integration: It acts as a wrapper around the
sfdmuplugin, which performs the actual data export operations. The command provides an assisted interface for SFDMU execution. exportDataUtility: The core logic for executing the SFDMU export process is encapsulated within theexportDatautility function, which takes the SFDMU workspace path and the source username as arguments.- Interactive Prompts: Uses
selectDataWorkspaceto allow the user to choose an SFDMU project andpromptOrgUsernameDefaultfor selecting the source Salesforce org when not running in a CI environment. - Environment Awareness: Checks the
isCIflag to determine whether to run in an interactive mode (prompting for user input) or a non-interactive mode (relying solely on command-line flags). - Required Plugin: It explicitly lists
sfdmuas a required plugin, ensuring that the necessary dependency is in place before execution.
Agent Mode
Use --agent to disable all prompts. Typical usage:
sf hardis:org:data:export --agent --path ./scripts/data/MyDataProject --target-org myOrg
- The
--pathflag (or--project-name) is required in agent mode (no interactive workspace selection). - The
--target-orgflag is used directly (no interactive org selection prompt). - The workspace content is still displayed, but its confirmation prompt is skipped.
Parameters
| Name | Type | Description | Default | Required | Options |
|---|---|---|---|---|---|
| agent | boolean | Run in non-interactive mode for agents and automation | |||
| debug -d |
boolean | Activate debug mode (more logs) | |||
| flags-dir | option | undefined | |||
| json | boolean | Format output as json. | |||
| no-prompt -r |
boolean | Do not prompt for Org, use default org | |||
| path -p |
option | Path to the sfdmu workspace folder | |||
| project-name -n |
option | Name of the sfdmu project to use (if not defined, you will be prompted to select one) | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| target-org -o |
option | undefined | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:org:data:export
$ sf hardis:org:data:export --project-name MyDataProject --target-org my-org@example.com
$ sf hardis:org:data:export --path ./scripts/data/MyDataProject --no-prompt --target-org my-org@example.com
$ sf hardis:org:data:export --agent --path ./scripts/data/MyDataProject --target-org myOrg
