154 lines
4.4 KiB
Bash
Executable File
154 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# entrypoint for all actions
|
|
#
|
|
|
|
# 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.2.4"
|
|
|
|
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 <archive> '
|
|
echo " show contents of archive (path from $NAS_ROOT)"
|
|
echo ' -r, --restore <archive> <file(s)> '
|
|
echo " restore files from archive to $RESTORE_PATH"
|
|
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
|
|
;;
|
|
--) # 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
|