mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
`/usr/bin/pg_dump` on Ubuntu and Debian is actually a tool which attempts to choose which `pg_dump` binary from all of the `postgresql-client-*` packages that are installed to run. However, its logic is confused by passing empty `--host` and `--port` options -- instead of looking at the running server instance on the server, it instead assumes some remote host and chooses the highest versioned `pg_dump` which is installed. Because Zulip writes binary database backups, they are sensitive to the version of the client `pg_dump` binary is used -- and the output may not be backwards compatible. Using a PostgreSQL 16 `pg_dump` writes archive format 1.15, which cannot be read by a PostgreSQL 15 `pg_restore`. Zulip does not currently support PostgreSQL 16 as a server. This means that backups on servers with `postgresql-client-16` installed did not successfully round-trip Zulip backups -- their backups are written using PostgreSQL 16's client, and the `pg_restore` chosen on restore was correctly chosen as the one whose version matched the server (PostgreSQL 15 or below), and thus did not understand the new archive format. Existing `./manage.py backups` taken since `postgresql-client-16` were installed are thus not directly usable by the `restore-backup` script. They are not useless, however, since they can theoretically be converted into a format readable by PostgreSQL 15 -- by importing into a PostgreSQL 16 instance, and re-dumping with a PostgreSQL 15 `pg_dump`. Fix this issue by hard-coding path to the binary whose version matches the version of the server we are connected to. This may theoretically fail if we are connected to a remote PostgreSQL instance and we do not have a `postgresql-client` package locally installed which matches the remote PostgreSQL server's version. However, choosing a matching version is the only way to ensure that it will be able to be imported cleanly -- and it is preferable that we fail the backup process rather than write backups that we cannot easily restore from. Fixes: #27160.
5.4 KiB
5.4 KiB