Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgres: change backup format from plain SQL to pg_dump custom #58

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

malor
Copy link
Member

@malor malor commented Sep 29, 2024

I'm experimenting with implementing the backup restore step and I ran into a few complications:

  • pg_restore does not like plain SQL and prefers this format they refer to as "custom"

  • psql does not allow us to change the role to xsnippet-api before restoring the backup in an Ansible task, so all objects end up being owned by the admin role postgres... And we can't use become because the system user xsnippet-api does not exist at that point yet

Switching to the custom format allows us to have this symmetry between pg_dump and pg_restore, and preserve/restore the correct owner value on all database objects. pg_restore also allows to skip the commands setting ownership, e.g. if we want to migrate to a different role.

@malor malor requested a review from ikalnytskyi September 29, 2024 20:58
I'm experimenting with implementing the backup restore step and I ran
into a few complications:

* pg_restore does not like plain SQL and prefers this format they refer
  to as "custom"

* psql does not allow us to change the role to `xsnippet-api` before
  restoring the backup in an Ansible task, so all objects end up being
  owned by the admin role `postgres`... And we can't use `become` because
  the system user `xsnippet-api` does not exist at that point yet

Switching to the custom format allows us to have this symmetry between
pg_dump and pg_restore, and preserve/restore the correct owner value on
all database objects. pg_restore also allows to skip the commands
setting ownership, e.g. if we want to migrate to a different role.
@malor malor merged commit e682fe4 into master Nov 16, 2024
3 checks passed
@malor malor deleted the backup-format branch November 16, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants