PostgreSQL for Debian and Ubuntu Apt Repository
===============================================

The PostgreSQL Global Development Group (PGDG) maintains an APT repository of
PostgreSQL packages for Debian and Ubuntu located at
https://apt.postgresql.org/pub/repos/apt/. We aim at building PostgreSQL server
packages as well as extensions and modules packages on several Debian/Ubuntu
releases for all PostgreSQL versions supported.

# Quickstart TL;DR

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

# Manual Repository Configuration

Import the repository key from https://www.postgresql.org/media/keys/ACCC4CF8.asc:

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 /etc/apt/sources.list.d/pgdg.sources. The distributions are called
codename-pgdg. In the example, replace "trixie" with the actual distribution
you are using. File contents:

Types: deb deb-src
URIs: https://apt.postgresql.org/pub/repos/apt
Suites: trixie-pgdg
Architectures: amd64
Components: main
Signed-By: /usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg

You may determine the codename of your distribution from VERSION_CODENAME in
/etc/os-release. For a script version of the above file creation, presuming you
are using a supported release:

. /etc/os-release
sudo tee /etc/apt/sources.list.d/pgdg.sources <<EOF
Types: deb deb-src
URIs: https://apt.postgresql.org/pub/repos/apt
Suites: $VERSION_CODENAME-pgdg
Architectures: $(dpkg --print-architecture)
Components: main
Signed-By: /usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg
EOF

Finally, update the package lists, and start installing packages:

sudo apt update
sudo apt install postgresql-18

# More information

* https://wiki.postgresql.org/wiki/Apt
* https://wiki.postgresql.org/wiki/Apt/FAQ
