Skip to content

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
@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.

3 participants