summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/app-pgchecksums.html
blob: 336df0336a09a296f54befaf2360981873bf5021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_checksums</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgarchivecleanup.html" title="pg_archivecleanup" /><link rel="next" href="app-pgcontroldata.html" title="pg_controldata" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_checksums</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCHECKSUMS"><div class="titlepage"></div><a id="id-1.9.5.5.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_checksums</span></span></h2><p>pg_checksums — enable, disable or check data checksums in a <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.5.4.1"><code class="command">pg_checksums</code> [<em class="replaceable"><code>option</code></em>...] [[ <code class="option">-D</code>  |   <code class="option">--pgdata</code> ]<em class="replaceable"><code>datadir</code></em>]</p></div></div><div class="refsect1" id="R1-APP-PGCHECKSUMS-1"><h2>Description</h2><p>
   <span class="application">pg_checksums</span> checks, enables or disables data
   checksums in a <span class="productname">PostgreSQL</span> cluster.  The server
   must be shut down cleanly before running
   <span class="application">pg_checksums</span>. 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.
  </p><p>
   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 <code class="filename">pg_control</code>.
  </p></div><div class="refsect1" id="id-1.9.5.5.6"><h2>Options</h2><p>
    The following command-line options are available:

    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
        Specifies the directory where the database cluster is stored.
       </p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--check</code></span></dt><dd><p>
        Checks checksums. This is the default mode if nothing else is
        specified.
       </p></dd><dt><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--disable</code></span></dt><dd><p>
        Disables checksums.
       </p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--enable</code></span></dt><dd><p>
        Enables checksums.
       </p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filenode</code></em></code><br /></span><span class="term"><code class="option">--filenode=<em class="replaceable"><code>filenode</code></em></code></span></dt><dd><p>
        Only validate checksums in the relation with filenode
        <em class="replaceable"><code>filenode</code></em>.
       </p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
        By default, <code class="command">pg_checksums</code> will wait for all files
        to be written safely to disk.  This option causes
        <code class="command">pg_checksums</code> 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 <code class="literal">--check</code>.
       </p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
        Enable progress reporting. Turning this on will deliver a progress
        report while checking or enabling checksums.
       </p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
        Enable verbose output. Lists all checked files.
       </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
        Print the <span class="application">pg_checksums</span> version and exit.
       </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
         Show help about <span class="application">pg_checksums</span> command line
         arguments, and exit.
        </p></dd></dl></div><p>
   </p></div><div class="refsect1" id="id-1.9.5.5.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
      Specifies the directory where the database cluster is
      stored; can be overridden using the <code class="option">-D</code> option.
     </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
      Specifies whether to use color in diagnostic messages. Possible values
      are <code class="literal">always</code>, <code class="literal">auto</code> and
      <code class="literal">never</code>.
     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.5.8"><h2>Notes</h2><p>
   Enabling checksums in a large cluster can potentially take a long time.
   During this operation, the cluster or other programs that write to the
   data directory must not be started or else data loss may occur.
  </p><p>
   When using a replication setup with tools which perform direct copies
   of relation file blocks (for example <a class="xref" href="app-pgrewind.html" title="pg_rewind"><span class="refentrytitle"><span class="application">pg_rewind</span></span></a>),
   enabling or disabling checksums can lead to page corruptions in the
   shape of incorrect checksums if the operation is not done consistently
   across all nodes. When enabling or disabling checksums in a replication
   setup, it is thus recommended to stop all the clusters before switching
   them all consistently. Destroying all standbys, performing the operation
   on the primary and finally recreating the standbys from scratch is also
   safe.
  </p><p>
   If <span class="application">pg_checksums</span> is aborted or killed while
   enabling or disabling checksums, the cluster's data checksum configuration
   remains unchanged, and <span class="application">pg_checksums</span> can be
   re-run to perform the same operation.
  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_archivecleanup</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_controldata</span></td></tr></table></div></body></html>