Prepare MariaDB restore tests and recover backup disk space safely
This commit is contained in:
1 parent
f0c761213d
commit
b0416461bc
23 files changed
+918
-129
No files matched your search
@@ -9,12 +9,14 @@ source "$LIB_DIR/common.sh"
|
||||
CONFIG_FILE=/etc/app-backup/app-backup.conf
|
||||
CHECK=false
|
||||
SKIP_RETENTION=false
|
||||
PREPARE_SPACE=false
|
||||
while (( $# )); do
|
||||
case $1 in
|
||||
--config) CONFIG_FILE=${2:?Missing config path}; shift 2 ;;
|
||||
--check) CHECK=true; shift ;;
|
||||
--prepare-space) PREPARE_SPACE=true; CHECK=true; shift ;;
|
||||
--no-retention) SKIP_RETENTION=true; shift ;;
|
||||
--help) echo 'Usage: app-backup.sh [--config FILE] [--check] [--no-retention]'; exit 0 ;;
|
||||
--help) echo 'Usage: app-backup.sh [--config FILE] [--check | --prepare-space] [--no-retention]'; exit 0 ;;
|
||||
*) die "Unknown argument: $1" ;;
|
||||
esac
|
||||
done
|
||||
@@ -22,6 +24,9 @@ OPERATION=backup
|
||||
load_config
|
||||
init_runtime
|
||||
build_plan
|
||||
# shellcheck source=lib/space.sh
|
||||
source "$LIB_DIR/space.sh"
|
||||
if [[ $CHECK == false || $PREPARE_SPACE == true ]]; then prepare_backup_space; fi
|
||||
preflight
|
||||
if [[ $CHECK == true ]]; then
|
||||
echo 'Preflight passed. Directory metadata probed; no application backup, service stop or upload performed.'
|
||||
@@ -75,6 +80,9 @@ assert_services_quiescent
|
||||
echo '-- Copy window complete; writer guards verified'
|
||||
BACKUP_PHASE='Dienste wiederherstellen'
|
||||
resume_services || die 'Failed to resume original service state'
|
||||
if [[ $ENABLE_MAIL_REPORT == true ]]; then
|
||||
python3 "$LIB_DIR/report.py" snapshot "$LOG_DIR/report_$RUN_ID.sizes.json" "$STAGING_DIR" "$PARTIAL_DIR" || echo 'WARNING: Report sizes unavailable'
|
||||
fi
|
||||
|
||||
while IFS=$'\t' read -r label _; do
|
||||
if [[ $label == meta ]]; then root=meta
|
||||
@@ -93,6 +101,9 @@ while IFS=$'\t' read -r label _; do
|
||||
gzip -6 -c > "$out.partial"
|
||||
fi
|
||||
mv -- "$out.partial" "$out"
|
||||
helper tar "$out" "$root"
|
||||
# Retain small metadata/plan for publication and recognized crash recovery.
|
||||
if [[ $label != meta ]]; then rm -rf -- "${STAGING_DIR:?}/$root"; fi
|
||||
done < "$PLAN"
|
||||
BACKUP_PHASE='Lokale Archivprüfung'
|
||||
helper create "$PARTIAL_DIR" "$RUN_ID" "$PLAN"
|
||||
|
||||
Reference in new issue
Block a user