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