CLI command reference
Complete reference for Infrahub Backup commands, flags, and options.
infrahub-backup
Command structure
infrahub-backup [global-flags] <command> [flags] [arguments]
Global flags
These flags apply to all infrahub-backup commands:
| Flag | Description | Default | Environment Variable |
|---|---|---|---|
--project <name> | Target specific Docker Compose project | Auto-detect | INFRAHUB_PROJECT |
--backup-dir <path> | Directory for backup files | ./infrahub_backups | INFRAHUB_BACKUP_DIR |
--log-format <text|json> | Output format for logs | text | INFRAHUB_LOG_FORMAT |
--s3-bucket <name> | S3 bucket name for backup storage | - | INFRAHUB_S3_BUCKET |
--s3-prefix <path> | S3 key prefix (path within bucket) | - | INFRAHUB_S3_PREFIX |
--s3-endpoint <url> | Custom S3 endpoint URL (for MinIO) | - | INFRAHUB_S3_ENDPOINT |
--s3-region <region> | AWS region for S3 bucket | us-east-1 | INFRAHUB_S3_REGION |
--help, -h | Show help for any command | - | - |
Backup commands
create
Creates a comprehensive backup of the Infrahub instance.
Syntax:
infrahub-backup create [flags]
Flags:
| Flag | Description | Default |
|---|---|---|
--force | Force backup even if tasks are running | false |
--neo4jmetadata <type> | Neo4j metadata to include | all |
--exclude-taskmanager | Exclude the task manager (Prefect) database from the backup archive | false |
--s3-upload | Upload backup to S3 after creation | false |
--s3-keep-local | Keep local backup file after S3 upload | false |
Neo4j metadata options:
all- Include all user and role metadatausers- Include only user accountsroles- Include only role definitionsnone- Exclude all metadata
Examples:
# Basic backup
infrahub-backup create
# Force backup with running tasks
infrahub-backup create --force
# Backup without user metadata
infrahub-backup create --neo4jmetadata=none
# Backup and upload to S3
infrahub-backup create --s3-upload --s3-bucket my-backups --s3-prefix infrahub/prod
# Backup and upload to S3, keeping local copy
infrahub-backup create --s3-upload --s3-bucket my-backups --s3-keep-local
restore
Restores Infrahub from a backup file or S3 URI.
Syntax:
infrahub-backup restore <backup-file|s3-uri>
Arguments:
<backup-file|s3-uri>- Path to backup archive or S3 URI (required)- Local file:
infrahub_backup_20250929_143022.tar.gz - S3 URI:
s3://bucket/prefix/infrahub_backup_20250929_143022.tar.gz
- Local file:
Flags:
| Flag | Description | Default |
|---|---|---|
--exclude-taskmanager | Skip restoring the task manager database even if the dump is present | false |
--migrate-format | Run Neo4j database format migration after restore | false |
Examples:
# Restore from local file
infrahub-backup restore infrahub_backup_20250929_143022.tar.gz
# Restore from S3
infrahub-backup restore s3://my-backups/infrahub/prod/infrahub_backup_20250929_143022.tar.gz
# Restore from MinIO
infrahub-backup restore --s3-endpoint http://minio.local:9000 s3://my-backups/infrahub_backup_20250929_143022.tar.gz
# Restore when the task manager database was excluded from the backup
infrahub-backup restore infrahub_backup_20251022_120000.tar.gz --exclude-taskmanager
Environment commands
environment detect
Detects and displays the current deployment environment.
Syntax:
infrahub-backup environment detect
Example output:
INFO[0000] Detecting deployment environment...
INFO[0000] Docker environment detected
INFO[0000] Found Docker Compose project: infrahub-demo
environment list
Lists all available Infrahub Docker Compose projects.
Syntax:
infrahub-backup environment list
Example output:
infrahub-production Running 7/7
infrahub-staging Running 7/7
infrahub-dev Stopped 0/7
Utility commands
version
Displays version information.
Syntax:
infrahub-backup version
Example output:
Version: 1.0.0
Configuration precedence
Configuration values are resolved in this order:
- Command-line flags (highest priority)
- Environment variables
- Default values (lowest priority)