skip to Main Content

I seem to have somehow deleted my postgres binaries (ubuntu 22.04).
Running sudo apt install postgresql postgresql-contrib reinstalled the binaries for the pg 14 cluster:

18:42 $ 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
13  main    5432 down,binaries_missing postgres /var/lib/postgresql/13/main /var/log/postgresql/postgresql-13-main.log
14  main    5432 online                postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log

Running sudo pg_createcluster --start 12 main gives Error: no initdb program for version 12 found

How do I reinstall postgres versions 12 and 13? I have existing databases in these clusters.

Also:

apt-cache showpkg postgresql

gives:

Package: postgresql
Versions: 
14+238 (/var/lib/apt/lists/ie.archive.ubuntu.com_ubuntu_dists_jammy_main_binary-amd64_Packages) (/var/lib/apt/lists/ie.archive.ubuntu.com_ubuntu_dists_jammy_main_binary-i386_Packages) (/var/lib/dpkg/status)

2

Answers


  1. Chosen as BEST ANSWER

    Following the instructions to use the pgdg repo, as advised by @Adrian Klaver, from here worked: postgresql.org/download/linux/ubuntu

    Then running sudo apt-get -y install postgresql-12


  2. I’ve actually run into something similar recently, having to install Postgresql-9.1 into a ubuntu 22.04. The default apt repo only has the 14 version, you can check this by runing the command:

    apt list | grep ^postgresql

    That being said, you must then configure an apt source that has the corresponding postgresql image(s) that you want. You can do so by following the instructions in the following link: https://wiki.postgresql.org/wiki/Apt. This is a link to configure your apt to use the postgres apt repo, which has most if not all postgresql images.

    After that you only need to list again:

    apt list | grep ^postgresql

    I recommend backing up your db files before, in case the installation overwrites anything

    and download your image with :

    apt install

    I can’t guarantee the binaries will have the same location or naming, so maybe you will need to do some configuration for the cluster.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search