17 lines
766 B
Bash
Executable file
17 lines
766 B
Bash
Executable file
#!/bin/sh
|
|
# Restore a Cordn coordinator backup into the cordn-data volume.
|
|
# Usage: ./restore.sh backups/cordn-YYYYMMDD-HHMMSS.tgz
|
|
set -eu
|
|
cd "$(dirname "$0")"
|
|
[ "$#" -eq 1 ] || { echo "usage: $0 backups/cordn-YYYYMMDD-HHMMSS.tgz" >&2; exit 1; }
|
|
archive="$1"
|
|
[ -f "$archive" ] || { echo "no such backup: $archive" >&2; exit 1; }
|
|
printf 'This replaces the current coordinator volume. Type "restore" to continue: '
|
|
read -r answer
|
|
[ "$answer" = restore ] || { echo "aborted" >&2; exit 1; }
|
|
docker run --rm \
|
|
-v cordn_cordn-data:/data \
|
|
-v "$(cd "$(dirname "$archive")" && pwd)":/backup:ro \
|
|
alpine:3.20 \
|
|
sh -c "rm -rf /data/* /data/.[!.]* /data/..?* 2>/dev/null || true; tar xzf /backup/$(basename "$archive") -C /data"
|
|
echo "Restored $(basename "$archive")."
|