Nam G VU
Nam G VU

Reputation: 35364

How to get remote pg_dump version?

When calling pg_dump to backup my database on remote server

pg_dump "postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_NAME" | gzip > $BACKUP_GZ  

I got below error

pg_dump: server version: 11.5 (Debian 11.5-3.pgdg90+1); pg_dump version: 10.14 (Ubuntu 10.14-0ubuntu0.18.04.1) pg_dump: aborting because of server version mismatch

Currently, I have to try-and-get as coded here to detect when pg_dump failed with the mismatch version and get the remote version there - which is a very tiring process.

So my question is what is fastest way to get that remote pg_dump version on remote server?

Upvotes: 1

Views: 646

Answers (1)

Nam G VU
Nam G VU

Reputation: 35364

Can simply just go for postgres version cause pg_dump/psql shares same version with postgres version

psql "postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT" -c 'select version()' -tA

Upvotes: 0

Related Questions