I run two instances of postgres servers - one on my local machine and the other one on my do virtual machine. Both of them are on debian. One of them was running 10.x and the other one 9.x version of postgres. I wanted to upgrade them to the latest version - that is version 11.
I was pleasantly surprised to see how simple it was. This is what I did:
Installed the version 11 of postgresql.
$ sudo apt install postgresql-11
Since I was already running an instance of postgresql, the installer setup the postgresql-11 on port 5433. Then I ran
pg_clclusters. This showed me that both versions of clusters are up and running.
Ver Cluster Port Status Owner Data directory Log file 10 main 5432 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log 11 main 5433 online postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
Next I rebooted the system and verified that both versions are running concurrently.
Now, for the final set of commands to move data from v10 to v11. Not commands, but just one command. Has to be executed as user
$ su postgres $ pg_dumpall -p 5432 | psql -d postgres -p 5433
I then tested the version 11 database by connecting and verifying the data.
Then I disabled v10 instance by going into
/etc/postgresql/10/main/start.conf. I just replaced
disabled. Finally, edited
/etc/postgresql/11/main/postgresql.conf to change the port from 5433 to 5432.
Then another reboot. After reboot, verified that only version 11 was up. And then ran some tests on my webapps to see if connections are okay.
That’s it. Its quite simple.