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
- Direct Download
- Manual Selection
- Build from Source
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/
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/
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:
-
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