2 .\" Title: pg_checksums
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "PG_CHECKSUMS" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 pg_checksums \- enable, disable or check data checksums in a PostgreSQL database cluster
33 .HP \w'\fBpg_checksums\fR\ 'u
34 \fBpg_checksums\fR [\fIoption\fR...] [[\fB\-D\fR | \fB\-\-pgdata\fR]\fIdatadir\fR]
38 checks, enables or disables data checksums in a
40 cluster\&. The server must be shut down cleanly before running
41 pg_checksums\&. 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\&.
43 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
47 The following command\-line options are available:
49 \fB\-D \fR\fB\fIdirectory\fR\fR
51 \fB\-\-pgdata=\fR\fB\fIdirectory\fR\fR
53 Specifies the directory where the database cluster is stored\&.
60 Checks checksums\&. This is the default mode if nothing else is specified\&.
77 \fB\-f \fR\fB\fIfilenode\fR\fR
79 \fB\-\-filenode=\fR\fB\fIfilenode\fR\fR
81 Only validate checksums in the relation with filenode
91 will wait for all files to be written safely to disk\&. This option causes
93 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
101 Enable progress reporting\&. Turning this on will deliver a progress report while checking or enabling checksums\&.
104 \fB\-\-sync\-method=\fR\fB\fImethod\fR\fR
107 fsync, which is the default,
109 will recursively open and synchronize all files in the data directory\&. The search for files will follow symbolic links for the WAL directory and each configured tablespace\&.
113 may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace\&. See
114 recovery_init_sync_method
115 for information about the caveats to be aware of when using
118 This option has no effect when
127 Enable verbose output\&. Lists all checked files\&.
145 command line arguments, and exit\&.
151 Specifies the directory where the database cluster is stored; can be overridden using the
158 Specifies whether to use color in diagnostic messages\&. Possible values are
166 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\&.
168 When using a replication setup with tools which perform direct copies of relation file blocks (for example
169 \fBpg_rewind\fR(1)), 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\&.
173 is aborted or killed while enabling or disabling checksums, the cluster\*(Aqs data checksum configuration remains unchanged, and
175 can be re\-run to perform the same operation\&.