-
Notifications
You must be signed in to change notification settings - Fork 6
Export Command
The export command retrieves Gateway configuration using GraphQL queries and saves it as a bundle file. This is the primary method for extracting configuration from a Gateway for backup, migration, or version control purposes.
graphman export [--using <query>] [--variables.<name> <value>,...] [--gateway <name>]
[--output <output-file>]
[--filter.<section>.<field-name> [<matching-criteria>.]<field-value>]
[--options.<name> <value>,...]| Parameter | Description | Default |
|---|---|---|
--using |
Name of the query to use for export | all |
--variables.<name> |
Variables for the query (name-value pairs) | None |
--gateway |
Gateway profile name from configuration | default |
--output |
Output file to save the exported bundle | Standard output (console) |
--filter.<section>.<field> |
Filter exported entities by field values | None |
--options.<name> |
Customize export operation (name-value pairs) | See defaults below |
| Option | Default Value | Description |
|---|---|---|
bundleDefaultAction |
NEW_OR_UPDATE |
Default mapping action for entities |
excludeDependencies |
false |
Exclude dependency entities |
excludeGoids |
false |
Exclude GOIDs from entities |
includePolicyRevisions |
false |
Include policy revision history |
- If no query is specified, the
allquery is used to export all Gateway entities - Custom queries can be specified to export specific entity types
- The client attempts to generate queries dynamically if they don't exist
- Only queries (not mutations) are valid for export operations
Filters can be applied at multiple levels:
-
Section-level filters: Apply to specific entity types (e.g.,
--filter.services.name) -
Global filters: Apply to all entity types using
*(e.g.,--filter.*.folderPath) - Multiple filters are combined with AND logic
| Criteria | Description | Example |
|---|---|---|
eq, equals
|
Exact match (default) | --filter.services.name.eq MyService |
neq |
Not equals | --filter.services.enabled.neq false |
regex |
Regular expression | --filter.services.name.regex ^API.* |
gt |
Greater than | --filter.policies.version.gt 5 |
lt |
Less than | --filter.policies.version.lt 10 |
gte |
Greater than or equals | --filter.services.version.gte 1 |
lte |
Less than or equals | --filter.services.version.lte 5 |
Export all Gateway configuration:
graphman export --gateway prod --output prod-config.jsonExport only services:
graphman export --using services --gateway prod --output services.jsonExport a specific service by name:
graphman export --using serviceByName --variables.name "My API Service" --gateway prod --output my-api.jsonExport services in a specific folder:
graphman export --using services --filter.services.folderPath.eq /APIs/External --gateway prod --output external-apis.jsonExport services matching a name pattern:
graphman export --using services --filter.services.name.regex "^Customer.*" --gateway prod --output customer-services.jsonInclude policy revision history:
graphman export --using all --options.includePolicyRevisions true --gateway prod --output full-backup.jsonExport only primary entities, excluding dependencies:
graphman export --using services --options.excludeDependencies true --gateway prod --output services-only.jsonExport configuration without Gateway Object IDs:
graphman export --using all --options.excludeGoids true --gateway prod --output portable-config.jsonExport an encapsulated assertion with its backing policy:
graphman export --using encass --variables.name "MyEncass" --gateway prod --output encass.jsonCreate a complete backup of Gateway configuration:
graphman export --gateway prod --output backups/prod-backup-$(date +%Y%m%d).jsonExport configuration for migration to another environment:
graphman export --using all --options.excludeGoids true --gateway dev --output migration-bundle.jsonExport only specific services for deployment:
graphman export --using services --filter.services.folderPath.eq /Release/v2.0 --gateway dev --output release-v2.0.jsonExport configuration for version control:
graphman export --gateway dev --output repo/gateway-config.json
git add repo/gateway-config.json
git commit -m "Updated gateway configuration"Export and analyze Gateway configuration:
graphman export --gateway prod --output analysis/prod-config.json
# Analyze the JSON file with other toolsRegular automated exports for disaster recovery:
#!/bin/bash
DATE=$(date +%Y%m%d-%H%M%S)
graphman export --gateway prod --output dr-backups/prod-$DATE.jsonPass multiple variables to a query:
graphman export --using customQuery \
--variables.name "MyService" \
--variables.enabled true \
--variables.folderPath "/APIs" \
--gateway prod --output result.jsonCombine multiple filters:
graphman export --using services \
--filter.services.enabled.eq true \
--filter.services.folderPath.regex "^/Production" \
--gateway prod --output prod-enabled-services.jsonExport services with server module files:
graphman export --using services \
--options.includeMultipartFields true \
--gateway prod --output services-with-modules.json- The Gateway must be accessible and the profile must be configured in
graphman.configuration - Export operations are read-only and do not modify the Gateway
- Large exports may take time depending on the Gateway size and network speed
- Exported bundles are in JSON format
- Policy revisions can significantly increase bundle size
- GOIDs are environment-specific; exclude them for portable bundles
- Filters are applied after data is retrieved from the Gateway
Common errors and solutions:
| Error | Solution |
|---|---|
| Gateway details are missing | Configure the Gateway profile in graphman.configuration
|
| Invalid query for export | Ensure the query starts with query (not mutation) |
| Connection timeout | Check Gateway accessibility and network connectivity |
| Query not found | Use describe command to list available queries |
- import: Import exported bundles to a Gateway
- describe: List and describe available queries
- diff: Compare exported bundles
- filter: Further filter exported bundles
- Use specific queries instead of
allwhen possible - Use
excludeDependenciesto reduce bundle size - Avoid
includePolicyRevisionsunless necessary - Use filters to limit the scope of export
- Export during off-peak hours for large configurations