Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/pg_rewind.sgml`
c445bdd2296e3e0a921d3f1c71a775f8dd7c438aa4ee103c0000000100000fa7
 to remove the data copied and restore back the set of links
    used before the rewind.
   </para>
  </warning>
 </refsect1>

 <refsect1>
  <title>Options</title>

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

    <variablelist>
     <varlistentry>
      <term><option>-D <replaceable class="parameter">directory</replaceable></option></term>
      <term><option>--target-pgdata=<replaceable class="parameter">directory</replaceable></option></term>
      <listitem>
       <para>
        This option specifies the target data directory that is synchronized
        with the source. The target server must be shut down cleanly before
        running <application>pg_rewind</application>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--source-pgdata=<replaceable class="parameter">directory</replaceable></option></term>
      <listitem>
       <para>
        Specifies the file system path to the data directory of the source
        server to synchronize the target with. This option requires the
        source server to be cleanly shut down.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--source-server=<replaceable class="parameter">connstr</replaceable></option></term>
      <listitem>
       <para>
        Specifies a libpq connection string to connect to the source
        <productname>PostgreSQL</productname> server to synchronize the target
        with. The connection must be a normal (non-replication) connection
        with a role having sufficient permissions to execute the functions
        used by <application>pg_rewind</application> on the source server
        (see Notes section for details) or a superuser role.  This option
        requires the source server to be running and accepting connections.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-R</option></term>
      <term><option>--write-recovery-conf</option></term>
      <listitem>
       <para>
        Create <filename>standby.signal</filename> and append connection
        settings to <filename>postgresql.auto.conf</filename> in the output
        directory.  The dbname will be recorded only if the dbname was
        specified explicitly in the connection string or <link linkend="libpq-envars">
        environment variable</link>. <literal>--source-server</literal> is
        mandatory with this option.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-n</option></term>
      <term><option>--dry-run</option></term>
      <listitem>
       <para>
        Do everything except actually modifying the target directory.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-N</option></term>
      <term><option>--no-sync</option></term>
      <listitem>
       <para>
        By default, <command>pg_rewind</command> will wait for all files
        to be written safely to disk.  This option causes
        <command>pg_rewind</command> to return without waiting, which is
        faster, but means that a subsequent operating system crash can leave
        the data directory corrupt.  Generally, this option is useful for
        testing but should not be used on a production
        installation.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-P</option></term>
      <term><option>--progress</option></term>
      <listitem>
       <para>
        Enables progress reporting. Turning this on will deliver an approximate
        progress report while copying data from the source cluster.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-c</option></term>
      <term><option>--restore-target-wal</option></term>
      <listitem>
       <para>
        Use <varname>restore_command</varname> defined in the target cluster

Title: pg_rewind Options: Target, Source, and Control
Summary
pg_rewind command-line options include specifying the target and source data directories or a connection string to the source server. The -D/--target-pgdata option defines the target data directory. The source can be specified with --source-pgdata (requiring a clean shutdown) or --source-server (using a connection string). -R/--write-recovery-conf creates standby.signal and appends connection settings. -n/--dry-run performs a dry run without modifying the target. -N/--no-sync disables waiting for disk writes. -P/--progress enables progress reporting. -c/--restore-target-wal uses restore_command to fetch missing WAL files.