Skip to content

Add VPS PostgreSQL backup/restore scripts and docs#31

Open
Spbd1 wants to merge 1 commit into
codex/create-google-sheets-apps-scriptfrom
codex/add-vps-backup/restore-scripts-for-postgresql
Open

Add VPS PostgreSQL backup/restore scripts and docs#31
Spbd1 wants to merge 1 commit into
codex/create-google-sheets-apps-scriptfrom
codex/add-vps-backup/restore-scripts-for-postgresql

Conversation

@Spbd1

@Spbd1 Spbd1 commented May 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide simple, safe VPS helpers to back up and restore the Docker Compose PostgreSQL database without exposing the DB port.
  • Make it easy to create timestamped off-server backups before updates or migrations and to restore only after explicit confirmation.
  • Keep local dump files out of the repository and document the recommended backup/restore workflow for VPS deployments.

Description

  • Add scripts/backup-postgres.sh, a strict Bash helper (set -euo pipefail) that reads POSTGRES_USER and POSTGRES_DB from .env with safe defaults hcg / hidden_cost_game, creates backups/, and runs docker compose exec -T postgres pg_dump to write a timestamped .sql file and print the output path.
  • Add scripts/restore-postgres.sh, which requires a backup file path argument, validates the file, prints a prominent warning, requires typing RESTORE to proceed, and streams the SQL into the DB with docker compose exec -T postgres psql (no DB port exposure).
  • Update docs/VPS_DEPLOYMENT.md to recommend running ./scripts/backup-postgres.sh before updates, explain where backups are stored, show scp examples for copying backups off/on the VPS, and document the restore warning and usage of ./scripts/restore-postgres.sh.
  • Add backups/ to .gitignore so repository-local dumps are not accidentally committed.

Testing

  • Shell static check: bash -n scripts/backup-postgres.sh scripts/restore-postgres.sh was run (shellcheck not available) and returned no syntax errors.
  • Typecheck: npm run typecheck completed successfully.
  • Lint: npm run lint completed successfully with no ESLint warnings.
  • Build: npm run build completed a successful Next.js production build and page generation.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant