CLI Commands Reference
Command Structure
terraback [global-options] <command> [command-options] [arguments]
Global Options
| Option | Short | Description |
|---|---|---|
--help | -h | Show help message |
--version | -v | Show version information |
--config | -c | Path to config file |
--profile | -p | Use specific profile |
--verbose | Enable verbose output | |
--debug | Enable debug logging | |
--json | Output in JSON format | |
--quiet | -q | Suppress non-error output |
--no-color | Disable colored output | |
--yes | -y | Auto-confirm prompts |
Core Commands
terraback init
Initialize Terraback in a Terraform project.
terraback init [options]
Options
--project PATH: Path to Terraform project (default: current directory)--storage TYPE: Storage backend type (s3, azure, gcp, local)--force: Overwrite existing configuration--import: Import existing backups
Examples
# Initialize in current directory
terraback init
# Initialize with S3 storage
terraback init --storage s3 --bucket my-backups
# Force reinitialize
terraback init --force
terraback backup
Manage state file backups.
Subcommands
backup create
terraback backup create [options]
Options:
--name NAME: Backup name--tags TAGS: Comma-separated tags--workspace WORKSPACE: Terraform workspace--compress: Enable compression--encrypt: Enable encryption--force: Overwrite if exists
Examples:
# Create named backup
terraback backup create --name "pre-deployment"
# Create tagged backup
terraback backup create --tags "production,critical,v2.0"
# Backup specific workspace
terraback backup create --workspace staging
backup list
terraback backup list [options]
Options:
--limit N: Number of results--since TIME: Show backups since time--until TIME: Show backups until time--tags TAGS: Filter by tags--workspace WORKSPACE: Filter by workspace--sort FIELD: Sort by field (date, size, name)
Examples:
# List recent backups
terraback backup list --limit 10
# List backups from last 24 hours
terraback backup list --since "24 hours ago"
# Filter by tags
terraback backup list --tags "production"
backup show
terraback backup show <backup-id>
Examples:
# Show backup details
terraback backup show backup_20240115_143022
# Show in JSON format
terraback backup show backup_20240115_143022 --json
backup delete
terraback backup delete <backup-id> [options]
Options:
--force: Skip confirmation--dry-run: Preview without deleting
Examples:
# Delete specific backup
terraback backup delete backup_20240115_143022
# Delete without confirmation
terraback backup delete backup_20240115_143022 --force
backup prune
terraback backup prune [options]
Options:
--older-than DURATION: Delete backups older than--keep-last N: Keep last N backups--keep-tags TAGS: Keep backups with tags--dry-run: Preview deletions--confirm: Confirm deletion
Examples:
# Preview pruning
terraback backup prune --older-than 30d --dry-run
# Prune old backups
terraback backup prune --older-than 30d --confirm
# Keep tagged backups
terraback backup prune --older-than 7d --keep-tags "release" --confirm
terraback restore
Restore from backups.
Subcommands
restore apply
terraback restore apply <backup-id> [options]
Options:
--confirm: Confirm restoration--force: Force restore without checks--backup-current: Backup current state first--workspace WORKSPACE: Target workspace
Examples:
# Restore backup
terraback restore apply backup_20240115_143022 --confirm
# Restore with current backup
terraback restore apply backup_20240115_143022 --backup-current --confirm
restore preview
terraback restore preview <backup-id>
Examples:
# Preview restoration
terraback restore preview backup_20240115_143022
# Compare with current
terraback restore preview backup_20240115_143022 --diff
restore selective
terraback restore selective <backup-id> [options]
Options:
--resource RESOURCE: Specific resources to restore--module MODULE: Specific modules to restore--exclude PATTERN: Exclude resources matching pattern
Examples:
# Restore specific resources
terraback restore selective backup_20240115_143022 \
--resource aws_instance.web \
--resource aws_s3_bucket.assets
# Restore module
terraback restore selective backup_20240115_143022 \
--module networking
terraback drift
Detect and manage configuration drift.
Subcommands
drift check
terraback drift check [options]
Options:
--fail-on-drift: Exit with error if drift detected--detailed: Show detailed drift information--ignore RESOURCE: Ignore specific resources
Examples:
# Check for drift
terraback drift check
# CI/CD integration
terraback drift check --fail-on-drift
# Ignore known drift
terraback drift check --ignore aws_instance.temporary
drift show
terraback drift show [options]
Options:
--format FORMAT: Output format (table, json, yaml)--severity LEVEL: Filter by severity (critical, warning, info)
Examples:
# Show all drift
terraback drift show
# Show critical drift only
terraback drift show --severity critical
# Export as JSON
terraback drift show --format json > drift.json
drift fix
terraback drift fix [options]
Options:
--dry-run: Preview fixes without applying--apply: Apply fixes--interactive: Choose fixes interactively--strategy STRATEGY: Fix strategy (reconcile, override, ignore)
Examples:
# Preview fixes
terraback drift fix --dry-run
# Apply all fixes
terraback drift fix --apply
# Interactive fix
terraback drift fix --interactive
terraback schedule
Manage backup schedules.
Subcommands
schedule create
terraback schedule create [options]
Options:
--name NAME: Schedule name--interval INTERVAL: Backup interval (1h, 6h, 1d)--retention DURATION: Retention period--time TIME: Specific time (for daily)--timezone TZ: Timezone for scheduling
Examples:
# Hourly backups
terraback schedule create --name hourly --interval 1h --retention 7d
# Daily backups at specific time
terraback schedule create --name daily --interval 1d --time 03:00 --timezone UTC
# Weekly backups
terraback schedule create --name weekly --interval 7d --retention 90d
schedule list
terraback schedule list
schedule delete
terraback schedule delete <schedule-name>
terraback checkpoint
Create and manage named checkpoints.
Subcommands
checkpoint create
terraback checkpoint create --name <name> [options]
Options:
--description DESC: Checkpoint description--tags TAGS: Checkpoint tags--expire DURATION: Auto-expire after duration
Examples:
# Create checkpoint
terraback checkpoint create --name "before-upgrade"
# Create with description
terraback checkpoint create \
--name "v2.0-release" \
--description "Before v2.0 deployment" \
--tags "release,production"
checkpoint list
terraback checkpoint list [options]
checkpoint restore
terraback checkpoint restore <checkpoint-name>
terraback config
Manage configuration settings.
Subcommands
config get
terraback config get <key>
Examples:
# Get specific setting
terraback config get storage.type
# Get all settings
terraback config get --all
config set
terraback config set <key> <value>
Examples:
# Set storage type
terraback config set storage.type s3
# Set retention period
terraback config set backup.retention 30d
# Enable encryption
terraback config set encryption.enabled true
config export
terraback config export [options]
Options:
--output FILE: Output file--format FORMAT: Export format (yaml, json)
config import
terraback config import <file>
terraback workspace
Manage Terraform workspaces.
Subcommands
workspace list
terraback workspace list
workspace backup
terraback workspace backup <workspace-name>
workspace restore
terraback workspace restore <workspace-name> <backup-id>
terraback status
Show Terraback status and health.
terraback status [options]
Options:
--detailed: Show detailed status--check-all: Run all health checks
Examples:
# Quick status
terraback status
# Detailed status
terraback status --detailed
# Full health check
terraback status --check-all
Advanced Commands
terraback export
Export backups and data.
terraback export [options]
Options:
--all: Export all backups--backup-id ID: Export specific backup--format FORMAT: Archive format (tar, zip)--output PATH: Output path
Examples:
# Export all backups
terraback export --all --output ./export.tar.gz
# Export specific backup
terraback export --backup-id backup_20240115_143022 --output ./backup.zip
terraback import
Import backups from archive.
terraback import <archive-file> [options]
Options:
--merge: Merge with existing backups--prefix PREFIX: Add prefix to imported backups
terraback diff
Compare states and backups.
terraback diff <source> <target>
Examples:
# Compare current with backup
terraback diff current backup_20240115_143022
# Compare two backups
terraback diff backup_20240115_143022 backup_20240115_150000
# Compare workspaces
terraback diff workspace:prod workspace:staging
terraback validate
Validate configuration and backups.
terraback validate [options]
Options:
--backup-id ID: Validate specific backup--all-backups: Validate all backups--fix: Attempt to fix issues
Examples:
# Validate configuration
terraback validate
# Validate all backups
terraback validate --all-backups
# Fix issues
terraback validate --fix
terraback doctor
Run system diagnostics.
terraback doctor [options]
Options:
--verbose: Verbose output--fix: Attempt to fix issues--report: Generate diagnostic report
Examples:
# Run diagnostics
terraback doctor
# Fix common issues
terraback doctor --fix
# Generate report
terraback doctor --report --output diagnostics.txt
Beta Commands
terraback beta
Access beta features (requires beta enrollment).
terraback beta [options]
Options:
--enable: Enable beta features--status: Show beta status--features: List beta features
Examples:
# Join beta program
terraback beta --enable
# Check beta status
terraback beta --status
# List available features
terraback beta --features
Integration Commands
terraback api
Interact with Terraback API.
terraback api <method> <endpoint> [options]
Options:
--data DATA: Request body--header HEADER: Add header
Examples:
# Get API status
terraback api GET /status
# Create backup via API
terraback api POST /backups --data '{"name":"api-backup"}'
terraback webhook
Manage webhooks.
terraback webhook <action> [options]
Actions:
create: Create webhooklist: List webhooksdelete: Delete webhooktest: Test webhook
Examples:
# Create Slack webhook
terraback webhook create \
--url https://hooks.slack.com/... \
--events "backup.created,drift.detected"
# Test webhook
terraback webhook test webhook_123
Output Formats
Most commands support multiple output formats:
# Table format (default)
terraback backup list
# JSON format
terraback backup list --json
# YAML format
terraback backup list --format yaml
# CSV format
terraback backup list --format csv
# No headers (scripting)
terraback backup list --no-headers
# Custom columns
terraback backup list --columns id,name,size
Environment Variables
Override configuration with environment variables:
# API Configuration
export TERRABACK_API_KEY="your-api-key"
export TERRABACK_API_URL="https://api.terraback.io"
# Storage Configuration
export TERRABACK_STORAGE_TYPE="s3"
export TERRABACK_STORAGE_BUCKET="my-backups"
export TERRABACK_STORAGE_REGION="us-east-1"
# Behavior Configuration
export TERRABACK_AUTO_BACKUP="true"
export TERRABACK_CONFIRM_ALL="true"
export TERRABACK_OUTPUT_FORMAT="json"
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Configuration error |
| 3 | Authentication error |
| 4 | Network error |
| 5 | Storage error |
| 6 | Drift detected (when using --fail-on-drift) |
| 7 | Validation error |
| 8 | Resource not found |
| 127 | Command not found |
Shell Completion
Enable shell completion for better CLI experience:
Bash
# Add to ~/.bashrc
source <(terraback completion bash)
Zsh
# Add to ~/.zshrc
source <(terraback completion zsh)
Fish
# Add to ~/.config/fish/config.fish
terraback completion fish | source
PowerShell
# Add to $PROFILE
terraback completion powershell | Out-String | Invoke-Expression