scripte/restore_menu.sh

131 lines
5.2 KiB
Bash
Executable File

#!/bin/bash
while true; do
clear
echo "==== Backup & Restore Menü ===="
echo "1) Komplettes Backup erstellen"
echo "2) Komplettes Restore durchführen"
echo "3) Einzelne Bereiche sichern (DB, Media, Static, Image, Config)"
echo "4) Einzelne Datenbank wiederherstellen"
echo "5) Media-Dateien wiederherstellen"
echo "6) Staticfiles wiederherstellen"
echo "7) Docker-Image importieren"
echo "8) Konfigurationsdatei wiederherstellen"
echo "q) Beenden"
echo
read -p "Bitte Auswahl eingeben: " auswahl
case $auswahl in
1)
/home/thomas/scripte/backup_docker.sh
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
2)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/restore_docker.sh "$ts"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
3)
while true; do
clear
echo "--- Einzelne Bereiche sichern ---"
echo "a) Einzelne Datenbank sichern"
echo "b) Media sichern"
echo "c) Staticfiles sichern"
echo "d) Docker-Image sichern"
echo "e) Konfigurationsdatei sichern"
echo "z) Zurück"
echo
read -p "Bitte Auswahl eingeben: " sub
case $sub in
a)
read -p "Containername (z für zurück): " ctn
[[ "$ctn" =~ ^[zZ]$ ]] && break
/home/thomas/scripte/Einzelne_Restore_Scripte/backup_db.sh "$ctn"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
b)
read -p "Projekt (webshop|ssv, z für zurück): " prj
[[ "$prj" =~ ^[zZ]$ ]] && break
/home/thomas/scripte/Einzelne_Restore_Scripte/backup_media.sh "$prj"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
c)
read -p "Projekt (webshop|ssv, z für zurück): " prj
[[ "$prj" =~ ^[zZ]$ ]] && break
/home/thomas/scripte/Einzelne_Restore_Scripte/backup_staticfiles.sh "$prj"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
d)
read -p "Image-Name (z.B. nginx:latest, z für zurück): " img
[[ "$img" =~ ^[zZ]$ ]] && break
/home/thomas/scripte/Einzelne_Restore_Scripte/backup_image.sh "$img"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
e)
read -p "Datei (docker-compose.yml|nginx.conf, z für zurück): " datei
[[ "$datei" =~ ^[zZ]$ ]] && break
/home/thomas/scripte/Einzelne_Restore_Scripte/backup_config.sh "$datei"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
z|Z)
break
;;
*)
echo "Ungültige Auswahl."
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && break
;;
esac
done
;;
4)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
read -p "Containername (z.B. db_webshop, z für zurück): " ctn
[[ "$ctn" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/Einzelne_Restore_Scripte/restore_db.sh "$ts" "$ctn"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
5)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
read -p "Projekt (webshop|ssv, z für zurück): " prj
[[ "$prj" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/Einzelne_Restore_Scripte/restore_media.sh "$ts" "$prj"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
6)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
read -p "Projekt (webshop|ssv, z für zurück): " prj
[[ "$prj" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/Einzelne_Restore_Scripte/restore_staticfiles.sh "$ts" "$prj"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
7)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
read -p "Image-Name (z.B. nginx_latest, z für zurück): " img
[[ "$img" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/Einzelne_Restore_Scripte/restore_image.sh "$ts" "$img"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
8)
read -p "Backup-Zeitstempel (z für zurück): " ts
[[ "$ts" =~ ^[zZ]$ ]] && continue
read -p "Datei (docker-compose.yml|nginx.conf, z für zurück): " datei
[[ "$datei" =~ ^[zZ]$ ]] && continue
/home/thomas/scripte/Einzelne_Restore_Scripte/restore_config.sh "$ts" "$datei"
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
q)
echo "Beende Menü."
exit 0
;;
*)
echo "Ungültige Auswahl."
read -p "Weiter mit Enter... (z für zurück)" z; [[ "$z" =~ ^[zZ]$ ]] && continue
;;
esac
done