xg env export
xg env export
Section titled “xg env export”Export registered Dataverse environment configurations from the local XrmGhost store to a portable JSON file. Use this command to back up your environment definitions, share them with teammates, or seed a fresh machine before running xg env import.
Pro tier required.
env exportis a feature-gated command. A valid XrmGhost Pro licence is required to run it. Seexg license statusto check your current tier.
Synopsis
Section titled “Synopsis”xg env export [FRIENDLY_NAME] [options]Description
Section titled “Description”When called without arguments, env export serialises the entire environment store — every configured Dataverse environment — to a single JSON file. Pass a FRIENDLY_NAME to export only that specific environment.
The output format is always indented JSON. The file contains the environment’s connection metadata (URL, tenant ID, client ID, etc.) but never the client secret: the ClientSecret field is unconditionally excluded from all exports at the model level.
If the target output path does not exist, the command creates the necessary directory structure before writing.
Default output path
Section titled “Default output path”When --output is omitted, the file is written to the user’s Downloads folder with an auto-generated name:
~/Downloads/XrmGhost_env_<sanitized_name>_<yyyyMMddHHmmss>.jsonFor a full-store export the placeholder all_environments is used in place of a friendly name:
~/Downloads/XrmGhost_env_all_environments_20260507153042.jsonOptions
Section titled “Options”| Flag | Argument | Required | Description |
|---|---|---|---|
[FRIENDLY_NAME] | string | No | The friendly name of the environment to export. When omitted, all registered environments are exported. |
-o, --output | <FILE_PATH> | No | Full path of the destination JSON file. If not specified, the file is saved to the Downloads folder with an auto-generated timestamped name. |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 | Export completed successfully (or no environments registered — nothing to export). |
1 | The specified FRIENDLY_NAME was not found, or an unexpected error occurred during export. |
Examples
Section titled “Examples”Export all environments (default path)
Section titled “Export all environments (default path)”xg env exportWrites all registered environments to ~/Downloads/XrmGhost_env_all_environments_<timestamp>.json.
Export all environments to a custom path
Section titled “Export all environments to a custom path”xg env export --output ./backups/environments.jsonExport a single environment by friendly name
Section titled “Export a single environment by friendly name”xg env export MyDevEnvironmentWrites only the MyDevEnvironment configuration to ~/Downloads/XrmGhost_env_MyDevEnvironment_<timestamp>.json.
Export a single environment to a specific file
Section titled “Export a single environment to a specific file”xg env export MyDevEnvironment --output ./exports/my-dev-env.jsonUse the export in a CI pipeline
Section titled “Use the export in a CI pipeline”xg env export --output /tmp/xg-environments.json# ... transfer file to the target machine ...xg env import /tmp/xg-environments.jsonOutput format
Section titled “Output format”The export produces a JSON file whose shape mirrors the internal D365EnvironmentsStore (full-store export) or a single D365EnvironmentConfiguration (single-environment export). Example excerpt for a single environment:
{ "FriendlyName": "MyDevEnvironment", "Url": "https://myorg.crm4.dynamics.com", "TenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "ClientId": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "IsActive": true}Note:
ClientSecretis always absent from exported files regardless of what is stored locally. When importing on another machine, you will be required to supply the secret again.
See Also
Section titled “See Also”xg env import— Import environment configurations from a JSON filexg env list— List all currently registered environments- CLI Reference — Full CLI reference landing page
- CLI Overview — Introduction to the XrmGhost CLI