1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!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 18.0 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>
3 <span class="application">pg_checksums</span> checks, enables or disables data
4 checksums in a <span class="productname">PostgreSQL</span> cluster. The server
5 must be shut down cleanly before running
6 <span class="application">pg_checksums</span>. When verifying checksums, the exit
7 status is zero if there are no checksum errors, and nonzero if at least one
8 checksum failure is detected. When enabling or disabling checksums, the
9 exit status is nonzero if the operation failed.
11 When verifying checksums, every file in the cluster is scanned. When
12 enabling checksums, each relation file block with a changed checksum is
14 Disabling checksums only updates the file <code class="filename">pg_control</code>.
15 </p></div><div class="refsect1" id="id-1.9.5.5.6"><h2>Options</h2><p>
16 The following command-line options are available:
18 </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>
19 Specifies the directory where the database cluster is stored.
20 </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>
21 Checks checksums. This is the default mode if nothing else is
23 </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>
25 </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>
27 </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>
28 Only validate checksums in the relation with filenode
29 <em class="replaceable"><code>filenode</code></em>.
30 </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>
31 By default, <code class="command">pg_checksums</code> will wait for all files
32 to be written safely to disk. This option causes
33 <code class="command">pg_checksums</code> to return without waiting, which is
34 faster, but means that a subsequent operating system crash can leave
35 the updated data directory corrupt. Generally, this option is useful
36 for testing but should not be used on a production installation.
37 This option has no effect when using <code class="literal">--check</code>.
38 </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>
39 Enable progress reporting. Turning this on will deliver a progress
40 report while checking or enabling checksums.
41 </p></dd><dt><span class="term"><code class="option">--sync-method=<em class="replaceable"><code>method</code></em></code></span></dt><dd><p>
42 When set to <code class="literal">fsync</code>, which is the default,
43 <code class="command">pg_checksums</code> will recursively open and synchronize
44 all files in the data directory. The search for files will follow
45 symbolic links for the WAL directory and each configured tablespace.
47 On Linux, <code class="literal">syncfs</code> may be used instead to ask the
48 operating system to synchronize the whole file systems that contain the
49 data directory, the WAL files, and each tablespace. See
50 <a class="xref" href="runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD">recovery_init_sync_method</a> for information about
51 the caveats to be aware of when using <code class="literal">syncfs</code>.
53 This option has no effect when <code class="option">--no-sync</code> is used.
54 </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>
55 Enable verbose output. Lists all checked files.
56 </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>
57 Print the <span class="application">pg_checksums</span> version and exit.
58 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
59 Show help about <span class="application">pg_checksums</span> command line
61 </p></dd></dl></div><p>
62 </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>
63 Specifies the directory where the database cluster is
64 stored; can be overridden using the <code class="option">-D</code> option.
65 </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
66 Specifies whether to use color in diagnostic messages. Possible values
67 are <code class="literal">always</code>, <code class="literal">auto</code> and
68 <code class="literal">never</code>.
69 </p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.5.8"><h2>Notes</h2><p>
70 Enabling checksums in a large cluster can potentially take a long time.
71 During this operation, the cluster or other programs that write to the
72 data directory must not be started or else data loss may occur.
74 When using a replication setup with tools which perform direct copies
75 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>),
76 enabling or disabling checksums can lead to page corruptions in the
77 shape of incorrect checksums if the operation is not done consistently
78 across all nodes. When enabling or disabling checksums in a replication
79 setup, it is thus recommended to stop all the clusters before switching
80 them all consistently. Destroying all standbys, performing the operation
81 on the primary and finally recreating the standbys from scratch is also
84 If <span class="application">pg_checksums</span> is aborted or killed while
85 enabling or disabling checksums, the cluster's data checksum configuration
86 remains unchanged, and <span class="application">pg_checksums</span> can be
87 re-run to perform the same operation.
88 </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 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_controldata</span></td></tr></table></div></body></html>