Compare commits
5 Commits
d090f5822f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b42ea3a648 | |||
| ac8183d527 | |||
| 5bd4874f2e | |||
| 61ba6f95ae | |||
| 90c978b944 |
@@ -6,6 +6,7 @@ SOURCE="/home/stefan"
|
||||
|
||||
# Passphrase sicher aus Datei lesen
|
||||
export BORG_PASSCOMMAND="cat /home/stefan/.config/borg/passphrase"
|
||||
export GOTIFY_TOKEN=$(cat /home/stefan/.config/gotify/token)
|
||||
|
||||
EXCLUDES=(
|
||||
"/home/stefan/docker/privatebin"
|
||||
@@ -21,7 +22,23 @@ EXCLUDES=(
|
||||
|
||||
BACKUP_NAME="backup-$(date +%Y-%m-%d_%H-%M-%S)"
|
||||
GOTIFY_URL="https://gotify.nauheimtech.de"
|
||||
GOTIFY_TOKEN=${GOTIFY_PW}
|
||||
|
||||
# Funktion zum Senden einer Nachricht an Gotify
|
||||
send_gotify_notification() {
|
||||
local message=$1
|
||||
local priority=$2
|
||||
curl -s -X POST "$GOTIFY_URL/message" \
|
||||
-H "X-Gotify-Key: $GOTIFY_TOKEN" \
|
||||
-d "title=Backup Fehler&message=$message&priority=$priority"
|
||||
}
|
||||
|
||||
# Teste SSH-Verbindung
|
||||
echo "===== Teste SSH-Verbindung: $(date) ====="
|
||||
if ! ssh -o BatchMode=yes -o ConnectTimeout=10 stefan@172.25.28.34 "echo Verbindung erfolgreich"; then
|
||||
send_gotify_notification "Backup fehlgeschlagen: Keine SSH-Verbindung möglich" 10
|
||||
echo "FEHLER: Keine SSH-Verbindung möglich am $(date)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Backup starten
|
||||
echo "===== Backup gestartet: $(date) ====="
|
||||
@@ -31,12 +48,8 @@ BACKUP_EXIT=$?
|
||||
|
||||
# Falls das Backup fehlschlägt, Nachricht an Gotify senden
|
||||
if [ $BACKUP_EXIT -ne 0 ]; then
|
||||
MESSAGE="Backup fehlgeschlagen: $BACKUP_NAME"
|
||||
PRIORITY=10
|
||||
send_gotify_notification "Backup fehlgeschlagen: $BACKUP_NAME" 10
|
||||
echo "FEHLER: Backup fehlgeschlagen ($BACKUP_NAME) am $(date)"
|
||||
curl -s -X POST "$GOTIFY_URL/message" \
|
||||
-H "X-Gotify-Key: $GOTIFY_TOKEN" \
|
||||
-d "title=Backup Fehler&message=$MESSAGE&priority=$PRIORITY"
|
||||
fi
|
||||
|
||||
# Alte Backups bereinigen
|
||||
|
||||
@@ -1,36 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setze Backup-Parameter
|
||||
REPO="ssh://stefan@172.25.28.34:22/srv/usbplatte/nauheim1vps"
|
||||
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:" 8 40 --title "Borg Backup" 3>&1 1>&2 2>&3)
|
||||
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 160
|
||||
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 160
|
||||
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() {
|
||||
ARCHIVE=$(whiptail --inputbox "Gib den Namen des Archivs ein:" 8 40 --title "Borg Backup" 3>&1 1>&2 2>&3)
|
||||
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 80
|
||||
rm /tmp/archive_info.txt
|
||||
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" 15 50 4 \
|
||||
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" \
|
||||
@@ -48,7 +72,7 @@ while true; do
|
||||
;;
|
||||
4)
|
||||
clear
|
||||
whiptail --msgbox "Beende das Skript." 8 40 --title "Borg Backup"
|
||||
whiptail --msgbox "Beende das Skript." 10 120 --title "Borg Backup"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -12,5 +12,5 @@ borg mount $REPO $MOUNT_POINT
|
||||
|
||||
echo "Das Backup-Repository wurde erfolgreich in $MOUNT_POINT gemountet."
|
||||
|
||||
# Zum Unmounten später den folgenden Befehl nutzen:
|
||||
# borg umount $MOUNT_POINT
|
||||
echo "Zum Unmounten später den folgenden Befehl nutzen:"
|
||||
echo "borg umount" $MOUNT_POINT
|
||||
|
||||
Reference in New Issue
Block a user