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:

  • Administrative or sudo access on your system
  • One of the following deployment environments:
    • Docker with Docker Compose (for Docker deployments)
    • kubectl configured with required permissions (for Kubernetes deployments)

If building from source:

  • Git and network access to clone the repository
  • Go 1.21 or later installed

Installation methods

Download the pre-built binary

If you want the fastest installation, 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

After installation, verify the tools are 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

Infrahub Backup use 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

Confirm the tools 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

System service installation

To run scheduled backups, install as 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