Files
nauheim1_borg/borg_info_anzeigen.sh

80 lines
2.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
clear
# Repository auswählen jetzt noch breiter!
REPO_OPTION=$(whiptail --title "Backup Repository auswählen" --menu "Wähle ein Repository oder gib eine eigene Adresse ein:" 20 120 2 \
"1" "Standard: ssh://stefan@172.25.28.34:22/srv/usbplatte/nauheim1vps" \
"2" "Eigene Eingabe" 3>&1 1>&2 2>&3)
if [ "$REPO_OPTION" == "1" ]; then
REPO="ssh://stefan@172.25.28.34:22/srv/usbplatte/nauheim1vps"
else
REPO=$(whiptail --inputbox "Gib das Repository ein:" 10 120 --title "Benutzerdefiniertes Repository" 3>&1 1>&2 2>&3)
fi
# Frage die Passphrase einmal ab
PASSPHRASE=$(whiptail --passwordbox "Bitte gib die Passphrase für das Borgbackup-Repository ein:" 10 120 --title "Borg Backup" 3>&1 1>&2 2>&3)
export BORG_PASSPHRASE="$PASSPHRASE"
# Funktion, um Informationen in einer scrollbaren Anzeige auszugeben
function show_repo_info() {
borg info "$REPO" > /tmp/repo_info.txt 2>&1
dialog --title "Repository-Informationen" --backtitle "Borg Backup" --scrollbar --textbox /tmp/repo_info.txt 25 240
rm /tmp/repo_info.txt
}
function list_archives() {
borg list "$REPO" > /tmp/archive_list.txt 2>&1
dialog --title "Verfügbare Archive" --backtitle "Borg Backup" --scrollbar --textbox /tmp/archive_list.txt 25 240
rm /tmp/archive_list.txt
}
function show_archive_details() {
ARCHIVES=$(borg list "$REPO" | awk '{print $1}')
if [ -z "$ARCHIVES" ]; then
whiptail --msgbox "Keine Archive gefunden!" 10 120 --title "Fehler"
return
fi
OPTIONS=()
while read -r line; do
OPTIONS+=("$line" " ")
done <<< "$ARCHIVES"
ARCHIVE=$(whiptail --title "Archiv auswählen" --menu "Wähle ein Archiv aus" 20 120 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
if [ -n "$ARCHIVE" ]; then
borg info "$REPO::$ARCHIVE" > /tmp/archive_info.txt 2>&1
dialog --title "Details zu Archiv $ARCHIVE" --backtitle "Borg Backup" --scrollbar --textbox /tmp/archive_info.txt 25 240
rm /tmp/archive_info.txt
fi
}
# Hauptmenü mit Whiptail
while true; do
OPTION=$(whiptail --title "Borg Backup Menü" --menu "Wähle eine Option" 20 120 4 \
"1" "Repository-Informationen anzeigen" \
"2" "Liste aller Archive anzeigen" \
"3" "Details zu einem bestimmten Archiv anzeigen" \
"4" "Beenden" 3>&1 1>&2 2>&3)
case $OPTION in
1)
show_repo_info
;;
2)
list_archives
;;
3)
show_archive_details
;;
4)
clear
whiptail --msgbox "Beende das Skript." 10 120 --title "Borg Backup"
exit 0
;;
esac
done