<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v 1.1 2002/08/17 02:45:29 momjian Exp $
PostgreSQL documentation
-->

<refentry id="APP-PGRESETXLOG">
 <refmeta>
  <refentrytitle id="APP-PGRESETXLOG-TITLE"><application>pg_resetxlog</application></refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>pg_resetxlog</refname>
  <refpurpose>reset write-ahead log file and optionally the pg_controldata file</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>pg_resetxlog</command>
   <arg><replaceable choice="plain">datadir</replaceable></arg>
  </cmdsynopsis>
 </refsynopsisdiv>

 <refsect1 id="R1-APP-PGRESETXLOG-1">
  <title>Description</title>
  <para>
   <command>pg_resetxlog</command> clears the write-ahead log file and
   optionally the <filename>pg_controldata</> file.  This is
   used so the server can be started after these files have become corrupted.
   (In every reported case, such file corruption has been caused 
   by faulty hardware.)  It is to be used only as a last resort,
   when the server will not start due to such corruption.
  </para>

  <para>
   After running this command, the server may contain index corruption and
   partially-committed transactions.  You should immediately dump your data
   and reload.  After reload, check for partially committed transactions 
   that may have been open at the time of the server crash.
  </para>

  <para>
   <command>pg_resetxlog</command> can also fix a corrupted
   <filename>pg_controldata</> file using the <literal>-f</>
   flag.  Use this option when <command>pg_resetxlog</> reports it can't
   reconstruct valid data for pg_control.
  </para>

  <para>
   <command>pg_resetxlog</command> has a few more options for
   special purposes.  Run the command with no arguments to see them.
  </para>

  <para>
   This utility can only be run by the user who installed the server because
   it requires read/write access to the <literal>datadir</>.
   For safety reasons, you must specify the data directory on the command line. 
   It does not use the environment variable <envar>PGDATA</>.
  </para>
 </refsect1>

 <refsect1>
  <title>Notes</title>

  <para>
   This command can not be used when the <application>postmaster</> is 
   running.
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
