gomask export
Export routine from database to YAML
gomask export
Export a routine from the GoMask database to YAML format.
Synopsis
gomask export ROUTINE_IDENTIFIER [OPTIONS]
Description
The export command downloads a routine configuration from GoMask and saves it as a YAML file. This is useful for:
- Backup: Save routine configurations before making changes
- Version control: Export routines to commit them to git
- Migration: Move routines between environments
- Editing: Export, modify locally, then re-import
Arguments
| Argument | Required | Description |
|---|---|---|
ROUTINE_IDENTIFIER | Yes | The routine ID (numeric) or unique identifier (string from routine.unique_id) |
Options
| Option | Type | Default | Description |
|---|---|---|---|
--output, -o PATH | path | stdout | Output file path. If not specified, prints to stdout. |
--force, -f | flag | false | Overwrite existing file without prompting |
--validate | flag | false | Validate the exported YAML after generation |
Examples
Export to File
gomask export customer-data-gen -o routine.yaml
Output:
Exporting routine 'customer-data-gen'...
✓ Exported to routine.yaml
Export to Stdout
gomask export customer-data-gen
Output:
routine:
name: "Customer Data Generator"
description: "Generates synthetic customer data"
type: synthetic
connector_id: 1
unique_id: "customer-data-gen"
tables:
- table_name: users
schema_name: public
hierarchy_level: 0
target_record_count: 1000
columns:
- column_name: email
generation_function: generate_email
...
Export by Numeric ID
gomask export 123 -o backup.yaml
Export with Validation
gomask export customer-data-gen -o routine.yaml --validate
Output:
Exporting routine 'customer-data-gen'...
✓ Exported to routine.yaml
Validating...
✓ Validation passed
Force Overwrite
gomask export customer-data-gen -o routine.yaml --force
Pipe to Another Command
gomask export customer-data-gen | yq '.tables[].table_name'
Output:
users
orders
products
order_items
Finding Routine Identifiers
List All Routines
gomask routines list
Output:
ID Identifier Name Type Tables
─── ────────────────── ────────────────────── ────────── ──────
123 customer-data-gen Customer Data Generator Synthetic 4
124 pii-masking-prod PII Masking Production Masking 8
125 test-data-staging Test Data Staging Synthetic 3
Show Routine Details
gomask routines show customer-data-gen
Exported YAML Structure
The exported YAML includes:
routine:
name: "Display Name"
description: "Description text"
type: synthetic # or masking
connector_id: 1
unique_id: "unique-identifier"
settings:
batch_size: 1000
generation_mode: hierarchical
runtime_parameter_definitions:
- key: "param_record_count"
name: "record_count"
type: integer
defaultValue: 1000
description: "Parameter description"
tables:
- table_name: table_name
schema_name: public
hierarchy_level: 0
target_record_count: 1000
columns:
- column_name: column_name
generation_function: function_name
generation_parameters:
- name: key
value: value
Export vs Backup
| Feature | Export | Backup (web UI) |
|---|---|---|
| Format | YAML | JSON |
| Includes history | No | Yes |
| Includes executions | No | Yes |
| Editable | Yes | No |
| Version control friendly | Yes | No |
Workflow: Edit and Re-import
# 1. Export existing routine
gomask export customer-data-gen -o routine.yaml
# 2. Edit the YAML
vim routine.yaml
# 3. Validate changes
gomask validate routine.yaml
# 4. Re-import with update flag
gomask import routine.yaml --update
Exit Codes
| Code | Description |
|---|---|
| 0 | Export successful |
| 1 | Export failed (routine not found, permission denied, etc.) |
Common Errors
Routine Not Found
Error: Routine 'unknown-routine' not found
Solutions:
- Check the identifier with
gomask routines list - Use the numeric ID instead of the string identifier
- Verify you have access to the routine's team
File Already Exists
Error: File 'routine.yaml' already exists. Use --force to overwrite.
Solutions:
- Use
--forceto overwrite - Specify a different output path