To do the upgrade , we have various options:
pg_dump & pg_restore
https://www.enterprisedb.com/postgres-tutorials/how-use-pgdump-and-pgrestore-multi-host-enviorment
pg_upgrade : Copy data on a binary level
pg_upgrade is not destructive.
If things go wrong, you can always delete the new data directory and start from scratch.
To upgrade a database, two steps are needed:
initdb -D /data/db_new
pg_upgrade -d /data/db_old/ -D /data/db_new -b /path/to/pg_old/bin/ -B /path/to/pg_new/bin/
pg_upgrade –link : In-place upgrades
To reduce downtime, we can use the << -link >> option:
pg_upgrade -d /data/db_old/ -D /data/db_new -b /path/to/pg_old/bin/ -B /path/to/pg_new/bin/ --link
https://www.cybertec-postgresql.com/en/upgrading-and-updating-postgresql/