feat: backup cron
CI / 🧪 Tests Laravel (push) Successful in 2m8s
CI / 🐳 Build & Push Image (push) Successful in 35s

This commit is contained in:
2026-08-13 14:20:28 +02:00
parent fd59e627cc
commit 334d94e712
8 changed files with 756 additions and 44 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/bin/sh
set -eu
compose_file="${COMPOSE_FILE:-docker-compose.yml}"
source_name="${1:-latest-s3}"
confirmation_phrase="replace-bowli-production-database"
if [ ! -f "$compose_file" ]; then
echo "Run this command from the daily-meal-api directory." >&2
exit 1
fi
echo "This operation will replace the production database."
echo "Backup source: $source_name"
printf "Type %s to continue: " "$confirmation_phrase"
read -r confirmation
if [ "$confirmation" != "$confirmation_phrase" ]; then
echo "Restoration cancelled."
exit 1
fi
docker compose -f "$compose_file" stop app horizon scheduler db-backup
if ! RESTORE_CONFIRM="$confirmation_phrase" docker compose \
-f "$compose_file" \
--profile restore \
run --rm db-restore "$source_name"
then
echo "Restoration failed. The application remains stopped to protect the database." >&2
echo "Inspect the logs, then restart it manually only when the database is safe." >&2
exit 1
fi
docker compose -f "$compose_file" up -d app horizon scheduler db-backup
echo "Application restarted after database restoration."