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