My OpenProject management software is installed with default postgresql 10. Currently the postgresql DB is 12, It is having lot of new features.
I want to upgrade my Postgres DB without losing the data in the DB. My system is ubuntu 18.04 and hosted openproject.
I searched the internet and could not find a step by step to upgrade postgresql.
Can you please guide me to install new DB and all data should be in the new DB. thanks for your help.
A) First create a backup of all the databases for that (You can continue from B if you dont need a backup)
sudo su postgres
pg_dumpall > backup.sql
B) Upgrade to PostgreSQL12
sudo apt-get update
sudo apt-get install postgresql-12 postgresql-server-dev-12
sudo systemctl stop postgresql.service
/usr/lib/postgresql/12/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/10/main \
--new-datadir=/var/lib/postgresql/12/main \
--old-bindir=/usr/lib/postgresql/10/bin \
--new-bindir=/usr/lib/postgresql/12/bin \
--old-options '-c config_file=/etc/postgresql/10/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf'
exit
#change port to 5432
sudo vim /etc/postgresql/12/main/postgresql.conf
#change port to 5433
sudo vim /etc/postgresql/10/main/postgresql.conf
sudo systemctl start postgresql.service
sudo su postgres
psql -c "SELECT version();"
./analyze_new_cluster.sh
#uninstalls postgres packages
sudo apt-get remove postgresql-10 postgresql-server-dev-10
#removes the old postgresql directory
sudo rm -rf /etc/postgresql/10/
#login as postgres user
sudo su postgres
#delete the old cluster data
./delete_old_cluster.sh
NOTE: Change the postgresql.conf and pg_hba.conf as per your requirement
PS: Feel free to comment your issues, suggestions or anyother modifications you would like to suggest