#!/bin/bash # # entrypoint for all actions # # 2.3.5. 20.12.2025 - fix not only logging but tar command itself # 2.3.4 19.12.2025 - fix tar param: --warning="no-file-ignored" # 2.3.3 18.12.2025 - smtp-relay läuft durch, dadurch ändern sich ggf. Dateien im Container, was # zu Fehlern beim tar führt. Deshalb wird das Verzeichnis # /var/home/container/.local/share/containers vom Backup ausgenommen. # Die Container-Overlays, die hier liegen können aus dem jeweiligen Image # wiederhergestellt werden, es geht also nichts verloren. # Außerdem kann tar über Sockets stolpern und unnötige Warnungen produzieren. # Abhilfe schafft der Parameter --warning=no-file-ignored. # Den mail delay im synology backup wieder entfernt. # 2.3.2 18.09.2025 - synology backup: wait 60 min before mailing # 2.3.1 16.08.2025 - 30 min delay for mail.sh # 2.3.0 12.08.2025 - new function for backup & encryption of Proton exports # 2.2.4 30.07.2025 - inc delay (again) for container startup-check (2m) # 2.2.3 24.06.2025 - Export-Disk kann exfat- oder vfat-formatiert sein # Export-Disk mit mehreren Partitonen erkennen # 2.2.2 19.06.2025 - inc delay for container startup check, fix error in log output # 2.2.1 16.06.2025 - delay container startup check # 2.2.0 16.05.2025 - fixes for auto-update, podman migration done # 2.1.17 11.05.2025 - bugfixes, sort tar archive, split daily/cron daily # 2.1.16 10.05.2025 - fix mail.sh, log results of auto-update # 2.1.15 09.05.2025 - podman auto-update # 2.1.14 09.05.2025 - Fix mail.sh, homeserver.target, cleared all docker references # 2.1.13 08.05.2025 - check if services are running after backup # 2.1.12 08.05.2025 - mail.sh an neuen Container angepasst # 2.1.11 05.05.2025 - Fix DB-Dump # 2.1.10 05.05.2025 - Postgres-Dump auf podman umgestellt # 2.1.9 02.05.2025 - DB-Dump erweitert, damit Dumps für mehrere postgres möglich sind # 2.1.8 30.04.2025 - systemctl start/stop eingebaut # 2.1.7 29.04.2025 - 1. Schritt zur Umstellung auf podman # 2.1.6 29.04.2025 - weekly backup Sa->SO VER="2.3.5" HERE=$(dirname "$0") THIS_SCRIPT=$0 show_help() { echo "Server Backup $VER" echo "usage: $0 options" echo " -d, --daily start daily backup on local machine" echo " -w, --weekly start weekly backup on local machine" echo " -e, --export export backups to USB-HDD" echo " -l, --list list archives" echo ' -c, --content ' echo " show contents of archive (path from $NAS_ROOT)" echo ' -r, --restore ' echo " restore files from archive to $RESTORE_PATH" echo " -p, --proton backup and encrypt Proton exports (MacBook only)" echo " -h, -?. --help show this help" echo " " echo " -d, -w, -e must be run as superuser." echo " " } if [ -f $HERE/main.inc.sh ]; then . $HERE/main.inc.sh else echo "**" echo "** ERROR: Datei \"$HERE/main.inc.sh\" nicht gefunden. " echo "** Script wird abgebrochen" echo "**" show_help exit 101 fi if [ -f $HERE/$HOST_NAME.sh ]; then . $HERE/$HOST_NAME.sh else echo "**" echo "** ERROR: Datei \"$HOST_NAME.sh\" nicht gefunden (falscher Rechner?). " echo "** Script wird abgebrochen." echo "**" show_help exit 102 fi file= archive= while :; do case $1 in -h|-\?|--help) show_help # Display a usage synopsis. exit 0 ;; --dx) MAIL_LOG_FILE="${log_file_name}.auto.log" check_root cron_backup_daily break ;; -d|--daily) MAIL_LOG_FILE="${log_file_name}.auto.log" check_root backup_daily break ;; -w|--weekly) MAIL_LOG_FILE="${log_file_name}.auto.log" check_root backup_weekly break ;; -e|--export) MAIL_LOG_FILE="${log_file_name}.auto.log" check_root export_backups break ;; -l|--list) list_archives break; ;; -c|--content) if [ "$2" ]; then list_archive_content "$2" else echo 'ERROR: "--content" requires the archive name as an argument.' echo show_help fi break ;; -r|--restore) if [ "$2" ]; then archive=$2 shift 2 restore "$archive" "$@" else echo 'ERROR: "--restore" requires at least the archive name as an argument.' echo show_help fi break ;; --rx) MAIL_LOG_FILE="${log_file_name}.auto.log" check_root shift do_restore $@ break ;; -p|--proton) MAIL_LOG_FILE="${log_file_name}.proton.log" check_mac proton_backup break ;; --) # End of all options. shift break ;; -?*) echo "WARN: Unknown option (ignored): $1" echo show_help exit ;; *) # Default case: No more options, so break out of the loop. break esac shift done exit 0