Skip to content

Update db:dump and db:backup tasks for modern PostgreSQL#63

Open
paranoicsan wants to merge 1 commit into
learningtapestry:masterfrom
paranoicsan:update-rake-db-tasks
Open

Update db:dump and db:backup tasks for modern PostgreSQL#63
paranoicsan wants to merge 1 commit into
learningtapestry:masterfrom
paranoicsan:update-rake-db-tasks

Conversation

@paranoicsan
Copy link
Copy Markdown
Contributor

@paranoicsan paranoicsan commented May 18, 2026

Summary

  • Rewrite pg_dump invocations in db:dump and db:backup using argument arrays with long flags and explicit = separators — required for compatibility with recent PostgreSQL client versions, which became stricter about argument parsing.
  • Pass the database name via explicit -d instead of as a positional argument.
  • Move backup path preparation (mkdir, date/timestamp) from a shell heredoc into Ruby (FileUtils.mkdir_p, Time.now).
  • Add post-run validation: fail with a clear message if pg_dump exits non-zero or the resulting file is missing/empty. Print the resulting path and size on success.

Test plan

  • bundle exec rubocop lib/tasks/db.rake — clean
  • rake db:backup — produced a non-empty dump under ~/database_backups/<date>/
  • rake db:dump — produced a non-empty db/dump/content.dump
  • rake db:pg_restore (left untouched in this PR) still works against the new dumps

- Rewrite pg_dump invocations using argument arrays with long flags and explicit `=` separators for compatibility with recent PostgreSQL versions
- Pass database name via explicit `-d` flag instead of positional argument
- Move backup path preparation (mkdir, timestamp) into Ruby using FileUtils and Time.now
- Add post-run validation: fail with a clear message if pg_dump exits non-zero or the resulting file is missing/empty
- Print the resulting file path and size on success

Signed-off-by: Alexander Kuznetsov <paranoic.san@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant