How to Start PostgreSQL on Boot in Debian Buster

debiandebian-busterpostgresqlsystemd

I have upgraded PostgreSQL from version 9.6 to 12 in Debian 10 Buster.
I'm currently running the 12 cluster, and I'm keeping the 9.6 cluster installed, but not running (down).

I can start the 12 main cluster with:

$ sudo pg_ctlcluster 12 main start
$ sudo pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.6 main    5433 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6 main.log
12  main    5432 online postgres /var/lib/postgresql/12/main  /var/log/postgresql/postgresql-12-main.log

But if I reboot with sudo reboot, it does not restart automatically on boot. After reboot I get the following message:

$ sudo pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.6 main    5433 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
12  main    5432 down   postgres /var/lib/postgresql/12/main  /var/log/postgresql/postgresql-12-main.log

How can I enable the 12 main cluster to automatically start on boot?

Best Answer

(I found the answer)

You need to edit the /etc/postgresql/12/main/start.conf file and replace manual with auto

$ sudo nano /etc/postgresql/12/main/start.conf    

# This cluster was upgraded to a newer major version. The old
# cluster has been preserved for backup purposes, but is not started
# automatically.

auto