From 89ed83239e117fb04dc93127798cb8702be2ed3d Mon Sep 17 00:00:00 2001 From: Jim Lancaster <40281233+zoltan57@users.noreply.github.com> Date: Wed, 26 Aug 2026 12:21:40 -0500 Subject: [PATCH] Update backup script to include everything needed to do a bare metal restore of the new V6 server --- README.md | 2 +- deploy/backup/create_postgres_backup.sh | 43 +++++++++++++++++++++--- deploy/backup/restore_postgres_backup.sh | 31 +++++++++++++++++ docs/backup_restore.md | 23 +++++++++---- docs/production-runbook.md | 3 +- 5 files changed, 88 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5f0ade9..7845ee9 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ See `docs/data_migration.md` for commands and cutover steps. ## Backup and restore workflow -Production PostgreSQL backup/restore steps are documented in `docs/backup_restore.md`. +Production backup/restore (PostgreSQL + uploads + deployment config) steps are documented in `docs/backup_restore.md`. ## Destructive test procedure (with data backup) diff --git a/deploy/backup/create_postgres_backup.sh b/deploy/backup/create_postgres_backup.sh index 13ae391..6e7574e 100644 --- a/deploy/backup/create_postgres_backup.sh +++ b/deploy/backup/create_postgres_backup.sh @@ -8,19 +8,52 @@ RETENTION_DAYS="${BACKUP_RETENTION_DAYS:-14}" SYNOLOGY_BACKUP_DIR="${SYNOLOGY_BACKUP_DIR:-}" timestamp="$(date -u +%Y%m%d-%H%M%S)" -backup_file="postgres-${timestamp}.dump" +postgres_file="postgres-${timestamp}.dump" +uploads_file="uploads-${timestamp}.tar.gz" +config_file="config-${timestamp}.tar.gz" +manifest_file="backup-${timestamp}.manifest" mkdir -p "${BACKUP_DIR}" docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" exec -T postgres sh -lc \ "PGPASSWORD=\"\$POSTGRES_PASSWORD\" pg_dump -U \"\$POSTGRES_USER\" -d \"\$POSTGRES_DB\" -Fc" \ - > "${BACKUP_DIR}/${backup_file}" + > "${BACKUP_DIR}/${postgres_file}" -find "${BACKUP_DIR}" -type f -name 'postgres-*.dump' -mtime +"${RETENTION_DAYS}" -delete +docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" run --rm --no-deps --entrypoint sh app -lc \ + "tar -C /app/uploads -czf - ." \ + > "${BACKUP_DIR}/${uploads_file}" + +tar -C . -czf "${BACKUP_DIR}/${config_file}" \ + "${ENV_FILE}" \ + "${COMPOSE_FILE}" \ + deploy/cloudflared/config.yml + +cat > "${BACKUP_DIR}/${manifest_file}" <` + - paired uploads/config artifacts (same timestamp) are restored automatically when present. ## 4. Post-release monitoring checklist