Skip to main content

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-backup Helm 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

Choose one of the following methods to install the CLI for Docker deployments:

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/

Verify installation

note

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

note

If you installed via Helm (in-band), configuration is managed through Helm values. 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

note

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:

  1. 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
  2. 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
  3. Enable and start:

    sudo systemctl enable infrahub-backup.timer
    sudo systemctl start infrahub-backup.timer