How to Install postgresql-client-11 on Ubuntu 18.04
-
24-02-2021 - |
Question
I need to use the pg_basebackup
/pg_dump
program on an Ubuntu 18.04 system to connect to a remote PostgreSQL 11.6 server.
However, the current system only contains pg_basebackup
10.10 and the remote database is using PostgreSQL 11.6. Running pg_basebackup
give the error
pg_basebackup: incompatible server version 11.6
Tried to install the correct version of pg_basebackup
using the command:
apt install postgresql-client-11
but the apt package is not found. Only postgresql-client
, postgresql-client-10
and postgresql-client-common
are available the system's apt repos.
Question: How can we install the correct version of pg_basebackup
without having to copy it over from the remote database server, and without installing PostgreSQL 11.6 on this machine?
Solution
Install it from PostgreSQL's own apt repository, adapted from these instructions.
sudo apt-get install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt install postgresql-client-11
pg_basebackup -V
pg_basebackup (PostgreSQL) 11.7 (Ubuntu 11.7-1.pgdg18.04+1)