Upgrading postgresql cluster from 15 to 16 with pg_upgradecluster

Did you already get this kind of trouble : after having upgraded OpenVas on a Kali VM (2023.3), the postgresl db need also to be upgraded from 15 to 16. The hints obtained with gvm-check-setup suggest to use pg_upgradecluster tool which need the old cluster name and location to be provided. The problem is that I really don’t know where to find this info, searching the web for that, unsuccessfully.
Can you help me build the correct syntax of this tool ?
Thank you

Here’s the syntax I’m looking for :
Usage: /usr/bin/pg_upgradecluster [OPTIONS] <old version> <cluster name> [<new data directory>]

Because this one raises an error :

pg_upgradecluster /var/lib/postgresql/15/main main
Use of uninitialized value $_[0] in concatenation (.) or string at /usr/share/perl5/PgCommon.pm line 1055.
Error: specified cluster does not exist

And this is what I get when I do pg_lscluster :

─# pg_lsclusters
Ver Cluster Port Status Owner    Data directory              Log file
15  main    5432 online postgres /var/lib/postgresql/15/main /var/log/postgresql/postgresql-15-main.log                                                                                                   
16  main    5433 online postgres /var/lib/postgresql/16/main /var/log/postgresql/postgresql-16-main.log

That is outside the GVM scope, but you can find the upgrade instructions at PostgreSQL.


Hi Lukas, I already checked this page, which is not really helpful for a beginner (no example given to use the command…). I continue on my researches,
Thank you for your help

HINT: If you run sudo apt update -y && sudo apt upgrade -y immediately after a fresh install of Kali, it will automatically upgrade the PG cluster and remove PG 15 for you.

1 Like

If you have issues maintaining a SQL Database, you should look for an appliance and not trying to maintain your GVM by your own.


Greenbone Cloud Service (GCS) is also a great option which allows you to avoid managing complex infrastructure. You can sign up for a free trial and the monthly costs are very reasonable.

While this is not a Greenbone related task / tool still cross-referencing a few existing threads in this forums giving more detailed external links / hints:


Will the data from the databases from version 15 to 16 be migrated in this case ?

The gvmd --migrate command is used to migrate the database schema in Greenbone Vulnerability Manager (GVMD). Someone can please correct me if I’m wrong, but that will update the PostgreSQL database schema when the GVM is updates include changes to the schema.

So, unless you are updating from a much older version of GVM, if you just want to migrate the database as is from PG-15 to PG-16, you need to dump the database and re-import it into PG-16. However, You may also encouter other problems unless you also install the other PostgreSQL components from pg-gvm.

Use the pg_dump command to create a backup of your PostgreSQL database. You’ll need to specify the database name, and you can also provide authentication options if necessary. Here’s a basic command:

pg_dump -U username -d dbname -p port_number -f dumpfile.sql

And to restore the data into PG-16

pg_restore -U username -d newdb -p port_number -f dumpfile.sql

I think I need use _gvm user because it’s owner of gvmd database

pg_dump -U _gvm -d gvmd -p 5432 -f dumpfile.sql
pg_dump: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "_gvm"

But i don’t know how to connect to it

su _gvm                                        
This account is currently not available.

The PostgreSQL user is not “_gvm”, it’s just “gvm”.


And you can’t su into the unix _gvmd user because it is a system user. You just can run things with its permissions for example via sudo -u _gvm <cmd>


I had the same problem - This worked for me

Btw. in the meanwhile @rippledj wrote some nice troubleshooting guide about this issue for our docs at https://greenbone.github.io/docs/latest/22.4/kali/troubleshooting.html