How to install Infrahub Backup
This guide shows you how to install Infrahub Backup on your system.
Prerequisites
Before installing Infrahub Backup, ensure you have:
For Docker deployments:
- Administrative or sudo access on your system
- Docker with Docker Compose installed
For Kubernetes deployments (in-band via Helm):
- Permissions to install or upgrade the
infrahub-backupHelm chart in your cluster
For Kubernetes deployments (out-of-band CLI):
- Administrative or sudo access on your system
- kubectl configured with permissions to access the Infrahub namespace
If building from source:
- Git and network access to clone the repository
- Go 1.21 or later installed
Installation methods
- Docker
- Kubernetes
Choose one of the following methods to install the CLI for Docker deployments:
- Direct Download
- Manual Selection
- Build from Source
Download the pre-built binary
Download the pre-built binary directly:
# Download the appropriate binary for your system
curl https://infrahub.opsmill.io/ops/$(uname -s)/$(uname -m)/infrahub-backup -o infrahub-backup
# Make it executable
chmod +x infrahub-backup
# Move to a directory in your PATH (optional)
sudo mv infrahub-backup /usr/local/bin/
Select and download a specific version
If you need a specific version or architecture, manually select the appropriate binary:
-
Identify your system architecture:
uname -s # Operating system (Linux/Darwin)
uname -m # Architecture (x86_64/aarch64) -
Download the matching binary:
- Linux AMD64:
curl -L https://infrahub.opsmill.io/ops/Linux/x86_64/infrahub-backup -o infrahub-backup - Linux ARM64:
curl -L https://infrahub.opsmill.io/ops/Linux/aarch64/infrahub-backup -o infrahub-backup - macOS AMD64:
curl -L https://infrahub.opsmill.io/ops/Darwin/x86_64/infrahub-backup -o infrahub-backup - macOS ARM64:
curl -L https://infrahub.opsmill.io/ops/Darwin/arm64/infrahub-backup -o infrahub-backup
- Linux AMD64:
-
Make executable and optionally install system-wide:
chmod +x infrahub-backup
sudo mv infrahub-backup /usr/local/bin/ # Optional
Build from source code
To install Infrahub Backup, build from source:
-
Install Go 1.21 or later:
# Check if Go is installed
go version -
Clone the repository:
git clone https://github.com/opsmill/infrahub-ops-cli.git
cd infrahub-ops-cli -
Build the binaries:
make build -
Install to your PATH:
sudo cp bin/infrahub-backup /usr/local/bin/
- Helm (In-band)
- CLI (Out-of-band)
Enable via Infrahub Helm chart (Recommended)
If you deploy Infrahub on Kubernetes using the Infrahub Helm chart, enable the infrahub-backup subchart. This in-band approach deploys backup functionality directly within your cluster—no separate CLI installation required.
# values.yaml for Infrahub Helm chart
infrahub-backup:
enabled: true
backup:
enabled: true
mode: "cronjob"
schedule: "0 2 * * *"
storage:
type: "s3"
s3:
bucket: "my-infrahub-backups"
endpoint: "https://s3.amazonaws.com"
region: "us-east-1"
secretName: "backup-s3-credentials"
Apply the configuration:
helm upgrade infrahub opsmill/infrahub \
--namespace infrahub \
--values values.yaml
This approach integrates backups with your existing Infrahub deployment and is ideal for GitOps workflows with ArgoCD or Flux.
For detailed configuration options, see:
Install the CLI for out-of-band operations
If you need to run backup operations from outside the cluster (for example, from a CI/CD pipeline or local workstation), install the CLI binary:
# Download the appropriate binary for your system
curl https://infrahub.opsmill.io/ops/$(uname -s)/$(uname -m)/infrahub-backup -o infrahub-backup
# Make it executable
chmod +x infrahub-backup
# Move to a directory in your PATH (optional)
sudo mv infrahub-backup /usr/local/bin/
Ensure kubectl is configured with access to the Infrahub namespace before running commands.
Verify installation
If you installed via Helm (in-band), skip this section—verification is handled by Kubernetes. The steps below apply to CLI installations only.
After installing the CLI, verify it is working correctly:
# Check versions
infrahub-backup version
# Verify environment detection
infrahub-backup environment detect
# Display help
infrahub-backup --help
Expected output:
Version: [git ref]
Configure environment
If you installed via Helm (in-band), configuration is managed through Helm values. See the Helm chart values reference for available options. The environment variables below apply to CLI installations only.
Infrahub Backup CLI uses environment variables for configuration. Set these based on your deployment:
Docker Compose deployments
# Optional: Target a specific project
export INFRAHUB_COMPOSE_PROJECT=infrahub-production
# Optional: Custom backup location
export BACKUP_DIR=/data/backups/infrahub
Kubernetes deployments
# Set the namespace
export INFRAHUB_K8S_NAMESPACE=infrahub
# Set kubeconfig if not default
export KUBECONFIG=/path/to/kubeconfig
Database credentials
If your deployment uses non-default credentials and the tools cannot fetch them automatically:
# Neo4j settings
export INFRAHUB_DB_USERNAME=neo4j
export INFRAHUB_DB_PASSWORD=your-password
export INFRAHUB_DB_DATABASE=neo4j
# PostgreSQL settings (for task manager)
export PREFECT_API_DATABASE_CONNECTION_URL=postgresql://user:pass@localhost/prefect
Validation
If you installed via Helm (in-band), validate your deployment by checking the CronJob status with kubectl get cronjobs -n infrahub. The steps below apply to CLI installations only.
Confirm the CLI can connect to your Infrahub instance:
# List available projects (Docker)
infrahub-backup environment list
# Test environment detection
infrahub-backup environment detect
If these commands succeed, installation is complete.
Advanced usage (Docker deployments)
System service installation
For Docker deployments, you can run scheduled backups using a systemd service:
-
Create service file:
sudo tee /etc/systemd/system/infrahub-backup.service > /dev/null <<EOF
[Unit]
Description=Infrahub Backup Service
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/infrahub-backup create
User=infrahub
Group=docker
[Install]
WantedBy=multi-user.target
EOF -
Create timer for daily backups:
sudo tee /etc/systemd/system/infrahub-backup.timer > /dev/null <<EOF
[Unit]
Description=Daily Infrahub Backup
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
EOF -
Enable and start:
sudo systemctl enable infrahub-backup.timer
sudo systemctl start infrahub-backup.timer