Thread: pg_upgrade as a way of cloning an instance?
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
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.
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
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.
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