postgresqldockerpg-restore

How to determine which pg_restore version to use with a given dump file?


I get the following error when running pg_restore

pg_restore: error: unsupported version (1.15) in file header

Versions the Docker container (running image postgres:14.10) provides

root@c33fdb601eab:/# postgres --version
postgres (PostgreSQL) 14.10 (Debian 14.10-1.pgdg120+1)
root@c33fdb601eab:/# pg_restore --version
pg_restore (PostgreSQL) 14.10 (Debian 14.10-1.pgdg120+1)

So what does this version 1.15 mean, please? Does it indicate the *.sql dump file version? If so, how do I know which pg_restore version to use to be able to restore it?

PS: clearly there are many similar posts already, but I didn't find an answer explaining how to match a dump file version to a pg_restore version.


Solution

  • It indicates the custom format version. The quickest way I found to find out is do:

    head <custom_dump_file>

    It should have at the top something like:

    test"14.10 (Ubuntu 14.10-1.pgdg22.04+1) 16.1 (Ubuntu 16.1-1.pgdg22.04+1).

    This is not the custom file format it just indicates a 14.10 instance of Postgres was dumped with a 16.1 version of pg_dump. You then know you have to use 16+ version of pg_restore. In other words pg_restore is backwards compatible but cannot restore a file that came from a pg_dump version that is newer then itself.