1PG_CHECKSUMS(1) PostgreSQL 15.4 Documentation PG_CHECKSUMS(1)
2
3
4
6 pg_checksums - enable, disable or check data checksums in a PostgreSQL
7 database cluster
8
10 pg_checksums [option...] [[-D | --pgdata]datadir]
11
13 pg_checksums checks, enables or disables data checksums in a PostgreSQL
14 cluster. The server must be shut down cleanly before running
15 pg_checksums. When verifying checksums, the exit status is zero if
16 there are no checksum errors, and nonzero if at least one checksum
17 failure is detected. When enabling or disabling checksums, the exit
18 status is nonzero if the operation failed.
19
20 When verifying checksums, every file in the cluster is scanned. When
21 enabling checksums, each relation file block with a changed checksum is
22 rewritten in-place. Disabling checksums only updates the file
23 pg_control.
24
26 The following command-line options are available:
27
28 -D directory
29 --pgdata=directory
30 Specifies the directory where the database cluster is stored.
31
32 -c
33 --check
34 Checks checksums. This is the default mode if nothing else is
35 specified.
36
37 -d
38 --disable
39 Disables checksums.
40
41 -e
42 --enable
43 Enables checksums.
44
45 -f filenode
46 --filenode=filenode
47 Only validate checksums in the relation with filenode filenode.
48
49 -N
50 --no-sync
51 By default, pg_checksums will wait for all files to be written
52 safely to disk. This option causes pg_checksums to return without
53 waiting, which is faster, but means that a subsequent operating
54 system crash can leave the updated data directory corrupt.
55 Generally, this option is useful for testing but should not be used
56 on a production installation. This option has no effect when using
57 --check.
58
59 -P
60 --progress
61 Enable progress reporting. Turning this on will deliver a progress
62 report while checking or enabling checksums.
63
64 -v
65 --verbose
66 Enable verbose output. Lists all checked files.
67
68 -V
69 --version
70 Print the pg_checksums version and exit.
71
72 -?
73 --help
74 Show help about pg_checksums command line arguments, and exit.
75
77 PGDATA
78 Specifies the directory where the database cluster is stored; can
79 be overridden using the -D option.
80
81 PG_COLOR
82 Specifies whether to use color in diagnostic messages. Possible
83 values are always, auto and never.
84
86 Enabling checksums in a large cluster can potentially take a long time.
87 During this operation, the cluster or other programs that write to the
88 data directory must not be started or else data loss may occur.
89
90 When using a replication setup with tools which perform direct copies
91 of relation file blocks (for example pg_rewind(1)), enabling or
92 disabling checksums can lead to page corruptions in the shape of
93 incorrect checksums if the operation is not done consistently across
94 all nodes. When enabling or disabling checksums in a replication setup,
95 it is thus recommended to stop all the clusters before switching them
96 all consistently. Destroying all standbys, performing the operation on
97 the primary and finally recreating the standbys from scratch is also
98 safe.
99
100 If pg_checksums is aborted or killed while enabling or disabling
101 checksums, the cluster's data checksum configuration remains unchanged,
102 and pg_checksums can be re-run to perform the same operation.
103
104
105
106PostgreSQL 15.4 2023 PG_CHECKSUMS(1)