Skip to main content

CLI command reference

Complete reference for the Infrahub Ops CLI tools (infrahub-backup, infrahub-collect), their 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:

FlagDescriptionDefaultEnvironment Variable
--forceForce backup even if tasks are runningfalseINFRAHUB_FORCE
--redactRedact all attribute values before backup (destructive, requires --force)falseINFRAHUB_REDACT
--neo4jmetadata <type>Neo4j metadata to includeallINFRAHUB_NEO4JMETADATA
--exclude-taskmanagerExclude the task manager (Prefect) database from the backup archivefalseINFRAHUB_EXCLUDE_TASKMANAGER
--s3-uploadUpload backup to S3 after creationfalseINFRAHUB_S3_UPLOAD
--s3-keep-localKeep local backup file after S3 uploadfalseINFRAHUB_S3_KEEP_LOCAL
--sleepSleep duration after backup for manual file transfer0INFRAHUB_SLEEP

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

# Create a redacted backup (replaces all attribute values with random UUIDs)
infrahub-backup create --redact --force

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
--reset-deployment-idGenerate a new Root node UUID after restore to detach this instance from the source deployment IDfalse

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

update​

Updates the running binary to a newer release. Downloads the matching artifact from GitHub Releases, verifies its SHA-256 checksum, and replaces the binary atomically. Available on both infrahub-backup and infrahub-collect.

Syntax:

infrahub-backup update [flags]

Flags:

FlagDescriptionDefault
--checkReport whether an update is available without installing itfalse
--yes, -ySkip the confirmation prompt (required for non-interactive use)false
--version <tag>Install a specific release (e.g. v1.7.2) instead of the latestlatest

Environment variables:

VariableDescription
GITHUB_TOKEN / GH_TOKENOptional GitHub token to raise the API rate limit on CI/shared IPs. Never required for normal use.

Self-update is refused for binaries installed via Homebrew or running inside a container image, for development builds, and when the binary location is not writable. See How to update the CLI.

infrahub-collect​

Command structure​

infrahub-collect [global-flags] <command> [flags]

Global flags​

These flags apply to all infrahub-collect commands:

FlagDescriptionDefaultEnvironment Variable
--project <name>Target specific Docker Compose projectAuto-detectINFRAHUB_PROJECT
--k8s-namespace <name>Target specific Kubernetes namespaceAuto-detectINFRAHUB_K8S_NAMESPACE
--output-dir <path>Directory for bundle files./infrahub_bundlesINFRAHUB_OUTPUT_DIR
--log-format <text|json>Output format for logstextINFRAHUB_LOG_FORMAT
--help, -hShow help for any command--

Collect commands​

create​

Collects a troubleshooting bundle from the Infrahub instance. Collection is read-only: no container or pod is stopped, restarted, or scaled. Individual collector failures are recorded in the bundle manifest and do not abort the run.

Syntax:

infrahub-collect create [flags]

Flags:

FlagDescriptionDefaultEnvironment Variable
--log-lines <n>Maximum log lines collected per container100000INFRAHUB_LOG_LINES
--include-backupAlso create a backup using the standard backup behaviorfalseINFRAHUB_INCLUDE_BACKUP
--include-queriesInclude database query logs (may contain customer data)falseINFRAHUB_INCLUDE_QUERIES
--benchmarkRun the OpsMill benchmark and include its results (requires image download; skipped with a warning if unavailable)falseINFRAHUB_BENCHMARK

Examples:

# Basic collection
infrahub-collect create

# Target a specific Kubernetes namespace
infrahub-collect create --k8s-namespace=infrahub-prod

# Collect with more log history
infrahub-collect create --log-lines=500000

# Collect logs and a backup in one run
infrahub-collect create --include-backup

# Performance investigation with benchmark
infrahub-collect create --benchmark

Output:

A single archive named support_bundle_<timestamp>.tar.gz in the output directory. Inside the archive, all files live under a top-level bundle/ directory, with a bundle_information.json manifest recording an explicit outcome for every collector.

Collectors:

CollectorWhat it gathers
Service logsContainer logs for every Infrahub service, all replicas, plus previous-container logs for restarted pods
Database logsNeo4j server logs (neo4j.log, debug.log); full log directory with --include-queries
Message-queue statusRabbitMQ queues, exchanges, bindings, connections, channels, and status
Cache statusRedis info, client list, configuration, slow log, and database size
Task-worker statePrefect worker status, one directory per replica
Task-manager stateWork pools, work queues, recent flow runs, events, and automations
Server infoVersions, installed packages, API information/configuration/schema, masked environment variables
Container metricsResource usage via docker compose stats or kubectl top
Backup (opt-in)Backup produced by the standard backup behavior (--include-backup)
Benchmark (opt-in)OpsMill benchmark results (--benchmark)

Environment and utility commands​

infrahub-collect provides the same environment detect, environment list, version, and update commands as infrahub-backup, with identical behavior. See update for the self-update flags and refusal cases.

Configuration precedence​

Configuration values are resolved in this order:

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