Home Explore Blog Models CI



postgresql

1st chunk of `doc/src/sgml/ref/pgupgrade.sgml`
0deb2cf2b28df021c049ab309c782bf6dc1b9f0ae36181f00000000100000fb1
<!--
doc/src/sgml/ref/pgupgrade.sgml
PostgreSQL documentation
-->

<refentry id="pgupgrade">
 <indexterm zone="pgupgrade">
  <primary>pg_upgrade</primary>
 </indexterm>

 <refmeta>
  <refentrytitle><application>pg_upgrade</application></refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>pg_upgrade</refname>
  <refpurpose>upgrade a <productname>PostgreSQL</productname> server instance</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>pg_upgrade</command>
   <arg choice="plain"><option>-b</option></arg>
   <arg choice="plain"><replaceable>oldbindir</replaceable></arg>
   <arg choice="opt"><option>-B</option> <replaceable>newbindir</replaceable></arg>
   <arg choice="plain"><option>-d</option></arg>
   <arg choice="plain"><replaceable>oldconfigdir</replaceable></arg>
   <arg choice="plain"><option>-D</option></arg>
   <arg choice="plain"><replaceable>newconfigdir</replaceable></arg>
   <arg rep="repeat"><replaceable>option</replaceable></arg>
  </cmdsynopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

 <para>
  <application>pg_upgrade</application> (formerly called <application>pg_migrator</application>) allows data
  stored in <productname>PostgreSQL</productname> data files to be upgraded to a later <productname>PostgreSQL</productname>
  major version without the data dump/restore typically required for
  major version upgrades, e.g., from 12.14 to 13.10 or from 14.9 to 15.5.
  It is not required for minor version upgrades, e.g., from 12.7 to 12.8
  or from 14.1 to 14.5.
 </para>

 <para>
  Major PostgreSQL releases regularly add new features that often
  change the layout of the system tables, but the internal data storage
  format rarely changes.  <application>pg_upgrade</application> uses this fact
  to perform rapid upgrades by creating new system tables and simply
  reusing the old user data files.  If a future major release ever
  changes the data storage format in a way that makes the old data
  format unreadable, <application>pg_upgrade</application> will not be usable
  for such upgrades.  (The community will attempt to avoid such
  situations.)
 </para>

 <para>
  <application>pg_upgrade</application> does its best to
  make sure the old and new clusters are binary-compatible, e.g.,  by
  checking for compatible compile-time settings, including 32/64-bit
  binaries.  It is important that
  any external modules are also binary compatible, though this cannot
  be checked by <application>pg_upgrade</application>.
 </para>

  <para>
   <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
   major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
  </para>
 </refsect1>

 <refsect1>
  <title>Options</title>

   <para>
    <application>pg_upgrade</application> accepts the following command-line arguments:

    <variablelist>

     <varlistentry>
      <term><option>-b</option> <replaceable>bindir</replaceable></term>
      <term><option>--old-bindir=</option><replaceable>bindir</replaceable></term>
      <listitem><para>the old PostgreSQL executable directory;
      environment variable <envar>PGBINOLD</envar></para></listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-B</option> <replaceable>bindir</replaceable></term>
      <term><option>--new-bindir=</option><replaceable>bindir</replaceable></term>
      <listitem><para>the new PostgreSQL executable directory;
      default is the directory where <application>pg_upgrade</application> resides;
      environment variable <envar>PGBINNEW</envar></para></listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-c</option></term>
      <term><option>--check</option></term>
      <listitem><para>check clusters only, don't change any data</para></listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-d</option> <replaceable>configdir</replaceable></term>

Title: pg_upgrade: Upgrading a PostgreSQL Server Instance
Summary
The `pg_upgrade` tool facilitates upgrading a PostgreSQL server instance to a newer major version without requiring a full data dump and restore. It works by creating new system tables and reusing existing user data files, enabling faster upgrades. The tool checks for binary compatibility between the old and new clusters but relies on the user to ensure external modules are compatible. `pg_upgrade` supports upgrades from version 9.2.X and later. It accepts command-line arguments for specifying the old and new PostgreSQL executable directories, checking clusters, and more.