Re: Help in vetting my steps for Postgres DB upgrade from Ver 13.X to ver 15.X

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: Bharani SV-forum <esteembsv-forum(at)yahoo(dot)com>
Cc: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Subject: Re: Help in vetting my steps for Postgres DB upgrade from Ver 13.X to ver 15.X
Date: 2024-12-04 15:46:32
Message-ID: CAKAnmmKZdhnhdNRd3OgDyEco9OPkT=qA_TeWMFMRvUM9pXauKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 4, 2024 at 7:42 AM Bharani SV-forum <esteembsv-forum(at)yahoo(dot)com>
wrote:

> a) is the above said steps is correct with the given existing and proposed
> setup
>

No. Here are some steps:

* Install Postgres on the new VM
However you get it, use the newest version you can. As of this writing, it
is Postgres 17.2. Version 15 is okay, but going to 17 now means a better
Postgres today, and no worrying about replacing v15 in three years.

* Create a new Postgres cluster
On the new VM, use the initdb command to create a new data directory.
Use the --data-checksums option

* Start it up
Adjust your postgresql.conf as needed
Adjust your pg_hba.conf as needed
Install any extensions used on the old VM
Start the cluster using the pg_ctl command (or systemctl)

* Test connection to the old vm from the new vm
On the new vm, see if you can connect to the old one:
psql -h oldvm -p 5432 --list
You may need to adjust firewalls and pg_hba.conf on the old vm.

* Copy the data
Run this on the new VM, adjusting ports as needed:
time pg_dumpall -h oldvm -p 5432 | psql -p 5432

Bonus points for doing this via screen/tmux to prevent interruptions

* Generate new statistics and vacuum
On the new vm, run:
psql -c 'vacuum freeze'
psql -c 'analyze'

* Test your application

* Setup all the other stuff (systemd integration, logrotate, cronjobs,
etc.) as needed

As Peter mentioned earlier, this can be done without disrupting anything,
and is easy to test and debug. The exact steps may vary a little, as I'm
not familiar with how Amazon Linux packages Postgres, but the basics are
the same.

Take it slow. Go through each of these steps one by one. If you get stuck
or run into an issue, stop and solve it, reaching out to this list as
necessary.

Cheers,
Greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Shershnev 2024-12-04 15:51:41 Seamless age (xid) replacement
Previous Message Ron Johnson 2024-12-04 14:49:33 Re: Help in vetting my steps for Postgres DB upgrade from Ver 13.X to ver 15.X