#!/bin/bash
# Version: 1.0
# Description: This script lists all the archives in a Borg repository
set -euo pipefail
# Check if whiptail is installed
if ! command -v whiptail &> /dev/null; then
echo "whiptail is required but not installed. Please install whiptail and try again."
exit 1
fi
# Set Variables
# ==============================================================================
# Hostname setup
SHORT_HOSTNAME=$(hostname -s)
# SSH key file location
SSH_KEY="/root/.ssh/id_ed25519_$SHORT_HOSTNAME"
# Backup server
REPO_SERVER="backup.servus.at"
# Backup repository location
REPO1="$SHORT_HOSTNAME@$REPO_SERVER:/./borg"
# Functions
# ==============================================================================
# Function to fetch and list Borg archives
list_archives() {
borg list "$REPO1" --rsh="ssh -i $SSH_KEY" 2>/dev/null
}
# Main Process
# ==============================================================================
# Fetch archives list
ARCHIVES=$(list_archives)
# Check if there are any archives to display
if [ -z "$ARCHIVES" ]; then
whiptail --title "Borg Archives" --msgbox "No archives found in repository: $REPO1" 8 78
exit 0
fi
# Display archives in a panel using whiptail
whiptail --title "Borg Archives" --scrolltext --msgbox "$ARCHIVES" 20 78
# ==============================================================================