Add restore verification and image-storage recovery scripts, update deployment documentation, and note the restore drill milestone in the implementation status.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${IMAGE_STORAGE_SOURCE:?Set IMAGE_STORAGE_SOURCE to the source image-storage directory}"
|
||||
: "${IMAGE_STORAGE_DESTINATION:?Set IMAGE_STORAGE_DESTINATION to the restore target directory}"
|
||||
|
||||
if [ ! -d "$IMAGE_STORAGE_SOURCE" ]; then
|
||||
printf '%s\n' "Image storage source not found: $IMAGE_STORAGE_SOURCE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$IMAGE_STORAGE_DESTINATION"
|
||||
cp -a "$IMAGE_STORAGE_SOURCE/." "$IMAGE_STORAGE_DESTINATION/"
|
||||
|
||||
printf '%s\n' "Image storage restored from $IMAGE_STORAGE_SOURCE to $IMAGE_STORAGE_DESTINATION"
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
test_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$test_dir"' EXIT
|
||||
|
||||
mkdir -p "$test_dir/source/subdir"
|
||||
printf '%s\n' 'hello' > "$test_dir/source/file.txt"
|
||||
mkdir -p "$test_dir/target"
|
||||
|
||||
IMAGE_STORAGE_SOURCE="$test_dir/source" \
|
||||
IMAGE_STORAGE_DESTINATION="$test_dir/target" \
|
||||
sh "$script_dir/restore-image-storage.sh" >/dev/null
|
||||
|
||||
[ -f "$test_dir/target/file.txt" ]
|
||||
[ "$(cat "$test_dir/target/file.txt")" = 'hello' ]
|
||||
|
||||
if IMAGE_STORAGE_SOURCE="$test_dir/missing" \
|
||||
IMAGE_STORAGE_DESTINATION="$test_dir/target" \
|
||||
sh "$script_dir/restore-image-storage.sh" >/dev/null 2>&1; then
|
||||
printf '%s\n' 'Expected missing source to fail.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s\n' 'restore-image-storage tests passed.'
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
test_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$test_dir"' EXIT
|
||||
mkdir -p "$test_dir/bin"
|
||||
|
||||
printf '%s\n' '#!/bin/sh' 'exit 0' > "$test_dir/bin/docker"
|
||||
chmod +x "$test_dir/bin/docker"
|
||||
|
||||
printf '%s\n' 'fake dump' > "$test_dir/backup.dump"
|
||||
PATH="$test_dir/bin:$PATH" \
|
||||
BACKUP_FILE="$test_dir/backup.dump" \
|
||||
POSTGRES_DB=inventory \
|
||||
POSTGRES_USER=inventory \
|
||||
POSTGRES_PASSWORD=secret \
|
||||
sh "$script_dir/restore-postgres.sh" >/dev/null
|
||||
|
||||
if BACKUP_FILE="$test_dir/empty.dump" \
|
||||
POSTGRES_DB=inventory \
|
||||
POSTGRES_USER=inventory \
|
||||
POSTGRES_PASSWORD=secret \
|
||||
sh "$script_dir/restore-postgres.sh" >/dev/null 2>&1; then
|
||||
printf '%s\n' 'Expected empty backup to fail.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if BACKUP_FILE="$test_dir/missing.dump" \
|
||||
POSTGRES_DB=inventory \
|
||||
POSTGRES_USER=inventory \
|
||||
POSTGRES_PASSWORD=secret \
|
||||
sh "$script_dir/restore-postgres.sh" >/dev/null 2>&1; then
|
||||
printf '%s\n' 'Expected missing backup to fail.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s\n' 'restore-postgres tests passed.'
|
||||
Reference in New Issue
Block a user