fix: use redis pre-cutover restore artifact

This commit is contained in:
2026-06-06 08:08:52 +02:00
parent 254eb81496
commit e3459c76d0
+18 -31
View File
@@ -4,7 +4,7 @@ set -euo pipefail
# Redis 8 Restore Smoke Test # Redis 8 Restore Smoke Test
# #
# Scope: # Scope:
# - Borg-Extract von /local/appdata/redis und redis_password.txt # - Restore aus dem dokumentierten shared-redis-pre-redis8-Artefakt
# - Start einer isolierten Redis-8-Testinstanz auf localhost:16379 # - Start einer isolierten Redis-8-Testinstanz auf localhost:16379
# - PING, INFO server und DBSIZE ohne Ausgabe des Passworts # - PING, INFO server und DBSIZE ohne Ausgabe des Passworts
@@ -23,7 +23,8 @@ done
RESTORE_ROOT="/mnt/user/backups/restore-lab/redis" RESTORE_ROOT="/mnt/user/backups/restore-lab/redis"
REPORT_ROOT="/mnt/user/backups/restore-reports" REPORT_ROOT="/mnt/user/backups/restore-reports"
EXTRACT_DIR="$BORG_RESTORE_HOST_ROOT/redis-extract" PRE_CUTOVER_ROOT="/mnt/user/backups/borg/dumps/latest"
SECRET_FILE="/mnt/user/appdata/secrets/redis_password.txt"
COMPOSE_FILE="$SCRIPT_DIR/redis-compose.test.yml" COMPOSE_FILE="$SCRIPT_DIR/redis-compose.test.yml"
REPORT_FILE="$REPORT_ROOT/redis-$(date +%F).md" REPORT_FILE="$REPORT_ROOT/redis-$(date +%F).md"
@@ -32,9 +33,8 @@ if [ "$WHATIF" -eq 1 ]; then
Redis 8 restore test Redis 8 restore test
Mode: WhatIf Mode: WhatIf
RestoreRoot: $RESTORE_ROOT RestoreRoot: $RESTORE_ROOT
Borg sources: Restore source: newest $PRE_CUTOVER_ROOT/shared-redis-pre-redis8-*
- local/appdata/redis Secret source: $SECRET_FILE
- local/appdata/secrets/redis_password.txt
Test endpoint: 127.0.0.1:16379 Test endpoint: 127.0.0.1:16379
Scope: Data restore + isolated Redis boot + PING/INFO/DBSIZE smoke Scope: Data restore + isolated Redis boot + PING/INFO/DBSIZE smoke
EOF EOF
@@ -42,7 +42,8 @@ EOF
fi fi
require_cmd docker require_cmd docker
require_path "$BORG_PASSPHRASE_FILE_DEFAULT" require_path "$PRE_CUTOVER_ROOT"
require_path "$SECRET_FILE"
require_path "$COMPOSE_FILE" require_path "$COMPOSE_FILE"
RESTORE_SUCCESS=0 RESTORE_SUCCESS=0
@@ -50,43 +51,30 @@ cleanup() {
cleanup_compose "$COMPOSE_FILE" cleanup_compose "$COMPOSE_FILE"
if [ "$RESTORE_SUCCESS" -ne 1 ]; then if [ "$RESTORE_SUCCESS" -ne 1 ]; then
preserve_on_failure "redis" "$RESTORE_ROOT" preserve_on_failure "redis" "$RESTORE_ROOT"
rm -rf "$EXTRACT_DIR"
return return
fi fi
if [ "$KEEP_DATA" -ne 1 ]; then if [ "$KEEP_DATA" -ne 1 ]; then
rm -rf "$RESTORE_ROOT" rm -rf "$RESTORE_ROOT"
fi fi
rm -rf "$EXTRACT_DIR"
} }
trap cleanup EXIT trap cleanup EXIT
rm -rf "$EXTRACT_DIR" "$RESTORE_ROOT" rm -rf "$RESTORE_ROOT"
mkdir -p "$RESTORE_ROOT/data" "$RESTORE_ROOT/secrets" mkdir -p "$RESTORE_ROOT/data" "$RESTORE_ROOT/secrets"
archive="$(latest_archive_name)" restore_source="$(find "$PRE_CUTOVER_ROOT" -maxdepth 1 -type d -name 'shared-redis-pre-redis8-*' | sort | tail -1)"
repo="$(borg_repo_url)" if [ -z "$restore_source" ]; then
echo "No shared-redis-pre-redis8-* restore source found under $PRE_CUTOVER_ROOT" >&2
if [ -z "$archive" ] || [ -z "$repo" ]; then
echo "Could not resolve Borg repo/archive from borg-ui database" >&2
exit 1 exit 1
fi fi
borg_extract "/restore/redis-extract" \ if [ ! -d "$restore_source" ]; then
"local/appdata/redis" \ echo "Redis restore source is not a directory: $restore_source" >&2
"local/appdata/secrets/redis_password.txt"
if [ ! -d "$EXTRACT_DIR/local/appdata/redis" ]; then
echo "Redis data path missing in Borg archive" >&2
exit 1 exit 1
fi fi
if [ ! -s "$EXTRACT_DIR/local/appdata/secrets/redis_password.txt" ]; then cp -a "$restore_source/." "$RESTORE_ROOT/data/"
echo "Redis password file missing in Borg archive" >&2 cp "$SECRET_FILE" "$RESTORE_ROOT/secrets/redis_password.txt"
exit 1
fi
cp -a "$EXTRACT_DIR/local/appdata/redis/." "$RESTORE_ROOT/data/"
cp "$EXTRACT_DIR/local/appdata/secrets/redis_password.txt" "$RESTORE_ROOT/secrets/redis_password.txt"
chmod -R a+rwX "$RESTORE_ROOT/data" chmod -R a+rwX "$RESTORE_ROOT/data"
chmod a+r "$RESTORE_ROOT/secrets/redis_password.txt" chmod a+r "$RESTORE_ROOT/secrets/redis_password.txt"
@@ -135,8 +123,7 @@ write_report "$REPORT_FILE" <<EOF
# Redis 8 Restore Test Report - $(date +%F) # Redis 8 Restore Test Report - $(date +%F)
- Service: \`redis\` - Service: \`redis\`
- Source repo: \`$repo\` - Restore source: \`$restore_source\`
- Archive: \`$archive\`
- Restore root: \`$RESTORE_ROOT\` - Restore root: \`$RESTORE_ROOT\`
- Test container: \`restoretest-redis\` - Test container: \`restoretest-redis\`
- Test endpoint: \`127.0.0.1:16379\` - Test endpoint: \`127.0.0.1:16379\`
@@ -144,8 +131,8 @@ write_report "$REPORT_FILE" <<EOF
## Checks ## Checks
- Borg extract of data path: \`ok\` - Data restore from pre-Redis8 artifact: \`ok\`
- Borg extract of secret file: \`ok\` - Secret file mounted from host secret path: \`ok\`
- Restored data files: \`$data_files\` - Restored data files: \`$data_files\`
- Restored data bytes: \`$data_bytes\` - Restored data bytes: \`$data_bytes\`
- PING: \`$ping_result\` - PING: \`$ping_result\`