Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/pg_checksums.sgml`
779d87ff3110ef41dadea1a3f8d679f4404a3d9adbecc4750000000100000fb0
<!--
doc/src/sgml/ref/pg_checksums.sgml
PostgreSQL documentation
-->

<refentry id="app-pgchecksums">
 <indexterm zone="app-pgchecksums">
  <primary>pg_checksums</primary>
 </indexterm>

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

 <refnamediv>
  <refname>pg_checksums</refname>
  <refpurpose>enable, disable or check data checksums in a <productname>PostgreSQL</productname> database cluster</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>pg_checksums</command>
   <arg rep="repeat" choice="opt"><replaceable class="parameter">option</replaceable></arg>
   <group choice="opt">
    <group choice="opt">
     <arg choice="plain"><option>-D</option></arg>
     <arg choice="plain"><option>--pgdata</option></arg>
    </group>
    <replaceable class="parameter">datadir</replaceable>
   </group>
  </cmdsynopsis>
 </refsynopsisdiv>

 <refsect1 id="r1-app-pgchecksums-1">
  <title>Description</title>
  <para>
   <application>pg_checksums</application> checks, enables or disables data
   checksums in a <productname>PostgreSQL</productname> cluster.  The server
   must be shut down cleanly before running
   <application>pg_checksums</application>. When verifying checksums, the exit
   status is zero if there are no checksum errors, and nonzero if at least one
   checksum failure is detected. When enabling or disabling checksums, the
   exit status is nonzero if the operation failed.
  </para>

  <para>
   When verifying checksums, every file in the cluster is scanned. When
   enabling checksums, each relation file block with a changed checksum is
   rewritten in-place.
   Disabling checksums only updates the file <filename>pg_control</filename>.
  </para>
 </refsect1>

 <refsect1>
  <title>Options</title>

   <para>
    The following command-line options are available:

    <variablelist>
     <varlistentry>
      <term><option>-D <replaceable>directory</replaceable></option></term>
      <term><option>--pgdata=<replaceable>directory</replaceable></option></term>
      <listitem>
       <para>
        Specifies the directory where the database cluster is stored.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-c</option></term>
      <term><option>--check</option></term>
      <listitem>
       <para>
        Checks checksums. This is the default mode if nothing else is
        specified.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-d</option></term>
      <term><option>--disable</option></term>
      <listitem>
       <para>
        Disables checksums.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-e</option></term>
      <term><option>--enable</option></term>
      <listitem>
       <para>
        Enables checksums.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-f <replaceable>filenode</replaceable></option></term>
      <term><option>--filenode=<replaceable>filenode</replaceable></option></term>
      <listitem>
       <para>
        Only validate checksums in the relation with filenode
        <replaceable>filenode</replaceable>.
       </para>
      </listitem>
     </varlistentry>

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

Title: pg_checksums: Enable, Disable, or Check Data Checksums in PostgreSQL
Summary
The pg_checksums application is used to check, enable, or disable data checksums in a PostgreSQL database cluster. The PostgreSQL server must be shut down cleanly before running pg_checksums. It can verify checksums by scanning every file, enable checksums by rewriting changed relation file blocks, or disable checksums by updating the pg_control file. Options include specifying the data directory, and enabling, disabling or checking checksums, as well as only validating checksums in a specific relation.