Skip to main content

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:

FlagDescriptionDefaultEnvironment Variable
--project <name>Target specific Docker Compose projectAuto-detectINFRAHUB_PROJECT
--backup-dir <path>Directory for backup files./infrahub_backupsINFRAHUB_BACKUP_DIR
--log-format <text|json>Output format for logstextINFRAHUB_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 bucketus-east-1INFRAHUB_S3_REGION
--help, -hShow help for any command--

Backup commands

create

Creates a comprehensive backup of the Infrahub instance.

Syntax:

infrahub-backup create [flags]

Flags:

FlagDescriptionDefault
--forceForce backup even if tasks are runningfalse
--neo4jmetadata <type>Neo4j metadata to includeall
--exclude-taskmanagerExclude the task manager (Prefect) database from the backup archivefalse
--s3-uploadUpload backup to S3 after creationfalse
--s3-keep-localKeep local backup file after S3 uploadfalse

Neo4j metadata options:

  • all - Include all user and role metadata
  • users - Include only user accounts
  • roles - Include only role definitions
  • none - 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

Flags:

FlagDescriptionDefault
--exclude-taskmanagerSkip restoring the task manager database even if the dump is presentfalse
--migrate-formatRun Neo4j database format migration after restorefalse

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:

  1. Command-line flags (highest priority)
  2. Environment variables
  3. Default values (lowest priority)