-1

To install PostgreSQL in either Debian or Ubuntu according with the official docs:

Exists the PostgreSQL Apt Repository section where exists two approaches:

Automated repository configuration:

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

To manually configure the Apt repository, follow these steps

# Import the repository signing key:
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc

# Create the repository configuration file:
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

# Update the package lists:
sudo apt update

If both approaches do theoretically the same configuration and obviously at a first glance the first approach is simpler than the latter due the amount of lines.

Question

  • When would be mandatory use the manually configure the Apt repository approach?

I read the PostgreSQL Apt Repository wiki page page but there is no an explicit explanation about when the manual (long) approach would be mandatory over the former.

1 Answer 1

3

Both those scripts install the same apt repo for apt.postgresql.org provided by PGDG. Subtle differences exist.

Do it yourself downloads the signing key from postgresql.org, while apt.postgresql.org.sh embeds it in Debian packages. In the unlikely event postgresql.org were compromised with a malicious key and packages signed with it, that would not be on the Debian mirrors, and apt would correctly complain.

apt.postgresql.org.sh has more robust detection and validation of major versions.

apt.postgresql.org.sh can purge the Debian packages and install PGDG ones. You may prefer not to do this, and maintain a complete package list somewhere else in your documentation and automation.

Given the robustness and reproducibility of using the actual script, my preference would be to always use apt.postgresql.org.sh

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.