ZettaIO / restic-compose-backup

Automatic restic backup of a docker-compose setup. https://hub.docker.com/r/zettaio/restic-compose-backup
MIT License
29 stars 16 forks source link

pg_dump version incompatibility #30

Open jannikw opened 4 years ago

jannikw commented 4 years ago

pg_dump is only backwards compatible not forward compatible. You can connect to and backup postgres databases for which the version is <= to the installed version of pg_dump. When attempting to backup a newer version the following error is displayed:

pg_dump: server version: 12.3 (Debian 12.3-1.pgdg100+1); pg_dump version: 11.7
pg_dump: aborting because of server version mismatch

Running pg_dump --version with the current docker image shows version 11.7 meaning postgres databases with major version 12 can't be backed up.

cschmatzler commented 4 years ago

Any update on this?

einarf commented 4 years ago

hmm. Need to look at how the image is built. Any insight to this is appreciated.

jannikw commented 4 years ago

This is not really fixable by adjusting the image, since you would have to ship every version of pg_dump as it is recommended to create the database dump with the exact version the database is running at. Though the latest version of pg_dump should be able to produce dumps for every previous version (up to some point), it is not guaranteed that these dumps can be restored with an older version, possibly the version the database is actually running at. This would kind of defeat the purpose of a backup if you cannot restore it :D See https://www.postgresql.org/docs/10/app-pgdump.html:

Because pg_dump is used to transfer data to newer versions of PostgreSQL, the output of pg_dump can be expected to load into PostgreSQL server versions newer than pg_dump's version. pg_dump can also dump from PostgreSQL servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, pg_dump cannot dump from PostgreSQL servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that pg_dump's output can be loaded into a server of an older major version — not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the --quote-all-identifiers option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different PostgreSQL versions.

einarf commented 4 years ago

So maybe the solution is to run pg_dump in the database container itself like suggested in #29

wehrstedt commented 2 years ago

So maybe the solution is to run pg_dump in the database container itself like suggested in #29

@einarf Is there any progress on this? Trying to use rcb with postgres 13.6. The suggestion in #29 seems to be a good solution?