pg_upgrade as a way of cloning an instance?

Started by Luca Ferrarialmost 5 years ago5 messagesgeneral
Jump to latest
#1Luca Ferrari
fluca1978@gmail.com

Hi all,
someone pointed me out that pg_upgrade can be used to do a clone of
the database, specifying the same binaries such as

pg_upgrade -B /usr/pgsql-13/bin -b /usr/pgsql-13/bin -D /data/clone -d /data/src

I tested it and it seems to work, even if I don't see any point in
running it (and most notably it requires a downtime on the original
cluster).
Any opinion about that?

Thanks,
Luca

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Luca Ferrari (#1)
Re: pg_upgrade as a way of cloning an instance?

On 07.07.21 08:53, Luca Ferrari wrote:

Hi all,
someone pointed me out that pg_upgrade can be used to do a clone of
the database, specifying the same binaries such as

pg_upgrade -B /usr/pgsql-13/bin -b /usr/pgsql-13/bin -D /data/clone -d /data/src

I tested it and it seems to work, even if I don't see any point in
running it (and most notably it requires a downtime on the original
cluster).
Any opinion about that?

Yeah, seems pretty pointless. You can just copy the data directory
directly and get the same effect. pg_upgrade basically does a data
directory copy plus some extra stuff to convert the system catalogs
between versions, and if you don't need that second part, you might as
well do the first part directly.

#3Luca Ferrari
fluca1978@gmail.com
In reply to: Peter Eisentraut (#2)
Re: pg_upgrade as a way of cloning an instance?

On Wed, Jul 7, 2021 at 10:22 AM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:

Yeah, seems pretty pointless. You can just copy the data directory
directly and get the same effect. pg_upgrade basically does a data
directory copy plus some extra stuff to convert the system catalogs
between versions, and if you don't need that second part, you might as
well do the first part directly.

Agree on everything, but I was curious, since users sometime find ways
to do things that are almost insane!

Thanks,
Luca

#4Bruce Momjian
bruce@momjian.us
In reply to: Luca Ferrari (#3)
Re: pg_upgrade as a way of cloning an instance?

On Wed, Jul 7, 2021 at 10:30:15AM +0200, Luca Ferrari wrote:

On Wed, Jul 7, 2021 at 10:22 AM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:

Yeah, seems pretty pointless. You can just copy the data directory
directly and get the same effect. pg_upgrade basically does a data
directory copy plus some extra stuff to convert the system catalogs
between versions, and if you don't need that second part, you might as
well do the first part directly.

Agree on everything, but I was curious, since users sometime find ways
to do things that are almost insane!

Also, pg_upgrade will throw an error if copying from one version to the
same version if there are tablespaces since the tablespace directory
name is the catalog version name.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.

#5Luca Ferrari
fluca1978@gmail.com
In reply to: Bruce Momjian (#4)
Re: pg_upgrade as a way of cloning an instance?

On Thu, Jul 8, 2021 at 2:30 AM Bruce Momjian <bruce@momjian.us> wrote:

Also, pg_upgrade will throw an error if copying from one version to the
same version if there are tablespaces since the tablespace directory
name is the catalog version name.

A very good point to discourage this usage!

Thanks,
Luca