Compare commits

..

6 Commits

Author SHA1 Message Date
5bd4874f2e Anpassungen erfolgt und erfolgreich 2025-05-19 21:27:30 +02:00
61ba6f95ae Option 3: Spaltenbreite ok 2025-05-19 21:22:34 +02:00
90c978b944 Option 3: Archivauswahl funktioniert 2025-05-19 21:20:22 +02:00
d090f5822f erste beide Optionen ok 2025-05-19 21:16:16 +02:00
afab977f61 Option 1 und 2 rudimentär lauffähig 2025-05-19 21:13:53 +02:00
3e32af6954 erste Grundversion 2025-05-19 21:09:15 +02:00

View File

@@ -1,34 +1,64 @@
#!/bin/bash #!/bin/bash
# Setze Backup-Parameter
REPO="ssh://stefan@172.25.28.34:22/srv/usbplatte/nauheim1vps"
clear clear
# Funktion, um Informationen anzuzeigen # 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() { function show_repo_info() {
echo "Repository-Informationen abrufen..." borg info "$REPO" > /tmp/repo_info.txt 2>&1
borg info $REPO dialog --title "Repository-Informationen" --backtitle "Borg Backup" --scrollbar --textbox /tmp/repo_info.txt 25 240
rm /tmp/repo_info.txt
} }
function list_archives() { function list_archives() {
echo "Verfügbare Archive im Repository:" borg list "$REPO" > /tmp/archive_list.txt 2>&1
borg list $REPO 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() { function show_archive_details() {
echo "Details zu einem bestimmten Archiv:" ARCHIVES=$(borg list "$REPO" | awk '{print $1}')
read -p "Gib den Namen des Archivs ein: " ARCHIVE
borg info $REPO::$ARCHIVE 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
} }
# Hauptskript: Wiederhole das Menü, solange der Nutzer nicht "Beenden" wählt # Hauptmenü mit Whiptail
while true; do while true; do
echo "Was möchtest du tun?" OPTION=$(whiptail --title "Borg Backup Menü" --menu "Wähle eine Option" 20 120 4 \
echo "1) Repository-Informationen anzeigen" "1" "Repository-Informationen anzeigen" \
echo "2) Liste aller Archive anzeigen" "2" "Liste aller Archive anzeigen" \
echo "3) Details zu einem bestimmten Archiv anzeigen" "3" "Details zu einem bestimmten Archiv anzeigen" \
echo "4) Beenden" "4" "Beenden" 3>&1 1>&2 2>&3)
read -p "Wähle eine Option (1-4): " OPTION
case $OPTION in case $OPTION in
1) 1)
@@ -41,14 +71,9 @@ while true; do
show_archive_details show_archive_details
;; ;;
4) 4)
echo "Beende das Skript." clear
whiptail --msgbox "Beende das Skript." 10 120 --title "Borg Backup"
exit 0 exit 0
;; ;;
*)
echo "Ungültige Eingabe. Bitte wähle eine Option zwischen 1 und 4."
;;
esac esac
# Warte kurz, bevor das Menü erneut angezeigt wird
echo ""
done done