# Export Command ## Overview 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. ## Syntax ```bash graphman export [--using ] [--variables. ,...] [--gateway ] [--output ] [--filter.
. [.]] [--options. ,...] ``` ## Parameters ### Optional Parameters | Parameter | Description | Default | |-----------|-------------|---------| | `--using` | Name of the query to use for export | `all` | | `--variables.` | 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.
.` | Filter exported entities by field values | None | | `--options.` | Customize export operation (name-value pairs) | See defaults below | ### Default Options | 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 | ## Behavior ### Query Selection - If no query is specified, the `all` query 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 ### Filtering 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 ### Supported Matching Criteria | 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` | ## Examples ### Basic Export Export all Gateway configuration: ```bash graphman export --gateway prod --output prod-config.json ``` ### Export Specific Entity Types Export only services: ```bash graphman export --using services --gateway prod --output services.json ``` ### Export by Name Export a specific service by name: ```bash graphman export --using serviceByName --variables.name "My API Service" --gateway prod --output my-api.json ``` ### Export with Filters Export services in a specific folder: ```bash graphman export --using services --filter.services.folderPath.eq /APIs/External --gateway prod --output external-apis.json ``` Export services matching a name pattern: ```bash graphman export --using services --filter.services.name.regex "^Customer.*" --gateway prod --output customer-services.json ``` ### Export with Policy Revisions Include policy revision history: ```bash graphman export --using all --options.includePolicyRevisions true --gateway prod --output full-backup.json ``` ### Export Without Dependencies Export only primary entities, excluding dependencies: ```bash graphman export --using services --options.excludeDependencies true --gateway prod --output services-only.json ``` ### Export Without GOIDs Export configuration without Gateway Object IDs: ```bash graphman export --using all --options.excludeGoids true --gateway prod --output portable-config.json ``` ### Export Encapsulated Assertion Export an encapsulated assertion with its backing policy: ```bash graphman export --using encass --variables.name "MyEncass" --gateway prod --output encass.json ``` ## Use Cases ### 1. Configuration Backup Create a complete backup of Gateway configuration: ```bash graphman export --gateway prod --output backups/prod-backup-$(date +%Y%m%d).json ``` ### 2. Environment Migration Export configuration for migration to another environment: ```bash graphman export --using all --options.excludeGoids true --gateway dev --output migration-bundle.json ``` ### 3. Selective Export Export only specific services for deployment: ```bash graphman export --using services --filter.services.folderPath.eq /Release/v2.0 --gateway dev --output release-v2.0.json ``` ### 4. Version Control Export configuration for version control: ```bash graphman export --gateway dev --output repo/gateway-config.json git add repo/gateway-config.json git commit -m "Updated gateway configuration" ``` ### 5. Configuration Analysis Export and analyze Gateway configuration: ```bash graphman export --gateway prod --output analysis/prod-config.json # Analyze the JSON file with other tools ``` ### 6. Disaster Recovery Regular automated exports for disaster recovery: ```bash #!/bin/bash DATE=$(date +%Y%m%d-%H%M%S) graphman export --gateway prod --output dr-backups/prod-$DATE.json ``` ## Advanced Features ### Multiple Variable Parameters Pass multiple variables to a query: ```bash graphman export --using customQuery \ --variables.name "MyService" \ --variables.enabled true \ --variables.folderPath "/APIs" \ --gateway prod --output result.json ``` ### Complex Filtering Combine multiple filters: ```bash graphman export --using services \ --filter.services.enabled.eq true \ --filter.services.folderPath.regex "^/Production" \ --gateway prod --output prod-enabled-services.json ``` ### Server Module Files Export services with server module files: ```bash graphman export --using services \ --options.includeMultipartFields true \ --gateway prod --output services-with-modules.json ``` ## Important Notes - 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 ## Error Handling 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 | ## Related Commands - **[import](Import-Command.md)**: Import exported bundles to a Gateway - **[describe](Describe-Command.md)**: List and describe available queries - **[diff](Diff-Command.md)**: Compare exported bundles - **[filter](Slice-Command.md)**: Further filter exported bundles ## Performance Tips 1. Use specific queries instead of `all` when possible 2. Use `excludeDependencies` to reduce bundle size 3. Avoid `includePolicyRevisions` unless necessary 4. Use filters to limit the scope of export 5. Export during off-peak hours for large configurations