2

I updated postgres to version 14 with sudo apt upgrade.

psql --version
psql (PostgreSQL) 14.1 (Ubuntu 14.1-2.pgdg20.04+1)

But pg_dump did not upgrade with everything else:

pg_dump --version
pg_dump (PostgreSQL) 12.9 (Ubuntu 12.9-2.pgdg20.04+1)

Any idea why that is?

I also purged everything postgres and reinstalled postgresql-14:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update

sudo apt-get -y install postgresql-14

But then:

pg_dump --version      
Error: PostgreSQL version 12 is not installed

Running Ubuntu 20.04.

Update:

Adding results of running pg_lsclusters

pg_lsclusters
Ver Cluster Port Status                Owner    Data directory              Log file
12  main    5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
14  main    5433 online                postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
4
  • Please add the result of pg_lsclusters. Dec 7 '21 at 10:46
  • 2
    It seems you have an older pg_dump somewhere on your PATH You can use which pg_dump to find out from where that binary is taken Dec 7 '21 at 11:36
  • @a_horse_with_no_name which pg_dump -> /usr/bin/pg_dump Dec 7 '21 at 12:15
  • @DanielVérité Added result of pg_lsclusters Dec 7 '21 at 12:17
3

The output of pg_lsclusters indicates that Postgres 12 binaries were uninstalled without removing the Postgres 12 instance first. Notice how the Status column says binaries_missing. The removal scripts takes special care not to destroy your data when you're uninstalling, which is why an instance and its data can be a bit sticky.

To remove the "zombie" instance, use

$ sudo pg_dropcluster 12 main

Then only the 14/main instance will remain in the pg_lsclusters list, and pg_dump and other client apps that go through the Debian/Ubuntu pg_wrapper script will stop choosing the 12/main instance first.

You may also want to relocate your 14/main instance to the 5432 port, as it's the default port for Postgres and if you don't plan to have several instances on the same host, using the default port will make your life easier.

1
  • It worked! I had ended up overriding the symlink but this is a proper solution. Thank you! Dec 7 '21 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.