Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/pg_resetwal.sgml`
1b43ed486365053a297f33175f1dc3f498c9b71f58ddb9760000000100000fbe
 inconsistencies and repair as needed.
  </para>

  <para>
   If <command>pg_resetwal</command> complains that it cannot determine
   valid data for <filename>pg_control</filename>, you can force it to proceed anyway
   by specifying the <option>-f</option> (force) option.  In this case plausible
   values will be substituted for the missing data.  Most of the fields can be
   expected to match, but manual assistance might be needed for the next OID,
   next transaction ID and epoch, next multitransaction ID and offset, and
   WAL starting location fields. These fields can be set using the options
   discussed below. If you are not able to determine correct values for all
   these fields, <option>-f</option> can still be used, but
   the recovered database must be treated with even more suspicion than
   usual: an immediate dump and restore is imperative.  <emphasis>Do not</emphasis>
   execute any data-modifying operations in the database before you dump,
   as any such action is likely to make the corruption worse.
  </para>

  <para>
   This utility can only be run by the user who installed the server, because
   it requires read/write access to the data directory.
  </para>
 </refsect1>

 <refsect1>
  <title>Options</title>

  <variablelist>
   <varlistentry>
    <term><replaceable class="parameter">datadir</replaceable></term>
    <term><option>-D <replaceable class="parameter">datadir</replaceable></option></term>
    <term><option>--pgdata=<replaceable class="parameter">datadir</replaceable></option></term>
    <listitem>
     <para>
      Specifies the location of the database directory.
      For safety reasons, you must specify the data directory on the command
      line.  <command>pg_resetwal</command> does not use the environment
      variable <envar>PGDATA</envar>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-f</option></term>
    <term><option>--force</option></term>
    <listitem>
     <para>
      Force <command>pg_resetwal</command> to proceed even in situations where
      it could be dangerous, as explained above.  Specifically, this option is
      required to proceed if the server had not been cleanly shut down or if
      <command>pg_resetwal</command> cannot determine valid data for
      <filename>pg_control</filename>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-n</option></term>
    <term><option>--dry-run</option></term>
    <listitem>
     <para>
      The <option>-n</option>/<option>--dry-run</option> option instructs
      <command>pg_resetwal</command> to print the values reconstructed from
      <filename>pg_control</filename> and values about to be changed, and then exit
      without modifying anything. This is mainly a debugging tool, but can be
      useful as a sanity check before allowing <command>pg_resetwal</command>
      to proceed for real.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-V</option></term>
    <term><option>--version</option></term>
    <listitem><para>Display version information, then exit.</para></listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-?</option></term>
    <term><option>--help</option></term>
    <listitem><para>Show help, then exit.</para></listitem>
   </varlistentry>
  </variablelist>

  <para>
   The following options are only needed when
   <command>pg_resetwal</command> is unable to determine appropriate values
   by reading <filename>pg_control</filename>.  Safe values can be determined as
   described below.  For values that take numeric arguments, hexadecimal
   values can be specified by using the prefix <literal>0x</literal>.  Note
   that these instructions only apply with the standard block size of 8 kB.
  </para>

  <variablelist>
   <varlistentry>
    <term><option>-c <replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></option></term>
    <term><option>--commit-timestamp-ids=<replaceable

Title: pg_resetwal: Continued Description, Options, and Usage
Summary
This section continues the description of pg_resetwal, emphasizing the importance of not modifying data before dumping a corrupted database. It also outlines the available command-line options. The tool must be run by the server's installer user due to data directory access requirements. Key options include specifying the data directory (-D/--pgdata), forcing the reset (-f/--force), and performing a dry run (-n/--dry-run). Additional options are available for situations where pg_resetwal cannot determine valid values from pg_control; they should be used with caution and with an understanding of how to determine safe values. Hexadecimal format is supported for numeric arguments.