Using pg_dump to upgrade data

In this recipe, we are going to upgrade the PostgreSQL cluster from version 9.5 to 9.6. We will utilize the pg_dump utility for this purpose.

Getting ready

The only prerequisites here are that an existing PostgreSQL cluster must be set up and running. The required version here is PostgreSQL Version 9.6. These steps are carried out on a 64 bit CentOS machine.

How to do it...

Here are the series of steps that need to be carried out for upgrading PostgreSQL from version 9.5 to 9.6 using pg_dump:

  1. Back up your database using pg_dumpall:
            pg_dumpall >  db.backup
    
  2. The next step would be to shut down the current PostgreSQL server:
            pg_ctl -D /var/lib/pgsql/9.5/data  stop
    
  3. Rename the old PostgreSQL installation directory:
     mv /var/lib/pgsql ...

Get PostgreSQL High Performance Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.