Files
tools-installer/BORG_CLI_INSTALLER_README.md

5.2 KiB

Borg CLI Installer

A comprehensive installer script for Borg CLI that supports multiple Linux distributions and installation methods.

Features

  • Version Checking: Only downloads and installs if newer version is available
  • Multiple Installation Methods:
    • Package manager (apt, yum, dnf, pacman, zypper)
    • Binary download from GitHub releases
  • Cross-Platform Support: Debian, Ubuntu, RHEL, CentOS, Fedora, Arch, openSUSE
  • Architecture Support: x86_64 (amd64), ARM64, ARM
  • Automatic Updates: Fetches latest version from GitHub API
  • Force Reinstall: Option to force reinstall even if up-to-date

Usage

Basic Usage

# Install latest version (only if newer than current)
./install-borg-cli.sh

# Install specific version
./install-borg-cli.sh -v 1.4.2

# Force reinstall even if up-to-date
./install-borg-cli.sh --force

Installation Methods

# Force installation from package manager
./install-borg-cli.sh --package

# Force installation from binary
./install-borg-cli.sh --binary

Help

./install-borg-cli.sh --help

Installation Logic

Version Checking

  1. Check Current Version: Detects installed Borg CLI version
  2. Fetch Latest: Gets latest version from GitHub API
  3. Compare Versions: Only proceeds if newer version available
  4. Force Override: --force flag bypasses version check

Installation Priority

  1. Package Manager (preferred):

    • Debian/Ubuntu: Checks for official borgbackup package
    • RHEL/CentOS/Fedora: Checks for available borgbackup package
    • Arch Linux: Available in pacman repositories
    • openSUSE: Checks for available borgbackup package
  2. Binary Download (fallback):

    • Downloads platform-specific binary from GitHub releases
    • Supports x86_64, ARM64, ARM architectures
    • Installs to /usr/local/bin/borg or ~/bin/borg

File Locations

Installation Directory

  • Binary: /usr/local/bin/borg (system) or ~/bin/borg (user)
  • Symlink: borg -> borg-1.4.2 (version-specific)

Version Comparison

The installer uses semantic version comparison:

  • Format: X.Y.Z (e.g., 1.4.2)
  • Logic: Compares major, minor, patch versions
  • Build Info: Ignores build hashes/identifiers

Examples

# Current: 1.4.0, Latest: 1.4.2 → Update needed
# Current: 1.4.2, Latest: 1.4.2 → No update needed
# Current: 1.4.3, Latest: 1.4.2 → No update needed (newer installed)

System Requirements

Required

  • curl or wget (for downloading)
  • sudo access (for system-wide installation)

Optional

  • Package manager access (for package installations)
  • Internet connection (for downloading releases)

Supported Distributions

Package Manager Support

  • Debian/Ubuntu: borgbackup package
  • RHEL/CentOS/Fedora: borgbackup package
  • Arch Linux: borg package
  • openSUSE: borgbackup package

Binary Support

  • Linux x86_64: borg-linux-glibc231-x86_64
  • Linux ARM64: borg-linux-glibc231-aarch64
  • Linux ARM: borg-linux-glibc231-armv7

Troubleshooting

Version Detection Issues

# Check current version manually
borg --version

# Force reinstall if version detection fails
./install-borg-cli.sh --force

Permission Issues

# For system installation
sudo ./install-borg-cli.sh --binary

PATH Issues

# Check if user bin is in PATH
echo $PATH | grep -q "$HOME/bin" && echo "OK" || echo "Add to PATH"

# Test borg command
which borg
borg --version

Examples

Typical Workflow

# Check if update needed
./install-borg-cli.sh

# Output if up-to-date:
# [SUCCESS] You already have latest version (1.4.2)
# [SUCCESS] No installation needed. Exiting.

# Output if update available:
# [INFO] Current version: 1.4.0 (user)
# [INFO] Latest version: 1.4.2
# [INFO] Newer version available: 1.4.2 > 1.4.0
# [SUCCESS] Installation completed successfully!

Force Binary Installation

# Force binary installation
./install-borg-cli.sh --force --binary

# Output:
# [SUCCESS] Borg CLI binary installed successfully
# Next steps:
# 1. Test installation: borg --version
# 2. Initialize repository: borg init --encryption=repokey /path/to/repo
# 3. Create backup: borg create /path/to/repo::backup-name /path/to/backup
# 4. Use Borg CLI: borg --help

Integration with Setup Script

The Borg CLI installer can be integrated with backup setup scripts:

  • Automatically called when Borg CLI is needed
  • Respects user preferences for installation location
  • Provides clear feedback on installation strategy
  • Handles both new installations and updates

Security Features

  • Official Releases: Downloads from official GitHub releases
  • Package Verification: Uses official package repositories
  • Proper Permissions: Sets appropriate file ownership and permissions

Contributing

To add support for new distributions or architectures:

  1. Update detect_os() function for new package managers
  2. Add architecture detection in get_arch() function
  3. Update installation methods in install_borg_from_*() functions
  4. Test with target distribution
  5. Update documentation

License

This installer script follows the same license as Borg (BSD-3-Clause).