Prepare MariaDB restore tests and recover backup disk space safely

This commit is contained in:
admin committed 2026-09-12 20:36:18 +02:00
1 parent f0c761213d
commit b0416461bc
23 files changed
+918 -129

No files matched your search

+10 -1
View File
@@ -18,7 +18,7 @@ done
[[ $NO_TIMER != true || $ENABLE_TIMER != true ]] || exit 1
# Syntax and packaging errors must be caught BEFORE changing the running installation.
for file in "$ROOT_DIR"/usr-local-sbin/*.sh "$ROOT_DIR"/lib/*.sh; do bash -n "$file"; done
python3 - "$ROOT_DIR/lib/backup_set.py" "$ROOT_DIR/lib/report.py" "$ROOT_DIR/lib/restore_test.py" <<'PY'
python3 - "$ROOT_DIR"/lib/*.py <<'PY'
import ast,sys
for path in sys.argv[1:]: ast.parse(open(path).read())
PY
@@ -65,6 +65,9 @@ if [[ -e /etc/systemd/system/app-restore-test.timer ]]; then
else add systemd/app-restore-test.timer /etc/systemd/system/app-restore-test.timer 644; fi
add lib/common.sh /usr/local/lib/app-backup/common.sh 640
add lib/locking.sh /usr/local/lib/app-backup/locking.sh 640
add lib/space.sh /usr/local/lib/app-backup/space.sh 640
add lib/space.py /usr/local/lib/app-backup/space.py 640
add lib/prepare-restore-test.sh /usr/local/lib/app-backup/prepare-restore-test.sh 640
add lib/backup_set.py /usr/local/lib/app-backup/backup_set.py 640
add lib/report.py /usr/local/lib/app-backup/report.py 640
add systemd/app-backup.service /etc/systemd/system/app-backup.service 644
@@ -81,6 +84,7 @@ add README.md /usr/local/share/doc/app-backup/README.md 644
add Dokumentation.md /usr/local/share/doc/app-backup/Dokumentation.md 644
add UPDATE_ANLEITUNG.md /usr/local/share/doc/app-backup/UPDATE_ANLEITUNG.md 644
add RESTORE_TEST.md /usr/local/share/doc/app-backup/RESTORE_TEST.md 644
add SPEICHER.md /usr/local/share/doc/app-backup/SPEICHER.md 644
# Save the exact replaced files plus a rollback inventory; do not dereference links.
: > "$SNAPSHOT/present.txt"; : > "$SNAPSHOT/absent.txt"
for i in "${!TARGETS[@]}"; do
@@ -138,6 +142,11 @@ for i in "${!TARGETS[@]}"; do
done
install -d -m 700 /var/log/app-backup /var/backups/app-backup
systemctl daemon-reload
# The coordinator prepares its candidate before install; direct installs prepare
# an already configured feature under this same lock before restarting timers.
if [[ ${APP_BACKUP_INHERIT_LOCK:-0} != 1 && ${ENABLE_RESTORE_TEST:-false} == true ]]; then
APP_BACKUP_INHERIT_LOCK=1 bash /usr/local/lib/app-backup/prepare-restore-test.sh /etc/app-backup/app-backup.conf
fi
# A persistent timer can fire immediately. Release the package lock only after
# all files are installed, but before that timer can start the new backup.
if [[ ${APP_BACKUP_INHERIT_LOCK:-0} != 1 ]]; then flock -u 9; fi