4 pg_checksums — enable, disable or check data checksums in a PostgreSQL
9 pg_checksums [option...] [[ -D | --pgdata ]datadir]
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.
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
27 The following command-line options are available:
31 Specifies the directory where the database cluster is stored.
35 Checks checksums. This is the default mode if nothing else is
48 Only validate checksums in the relation with filenode filenode.
52 By default, pg_checksums will wait for all files to be written
53 safely to disk. This option causes pg_checksums to return
54 without waiting, which is faster, but means that a subsequent
55 operating system crash can leave the updated data directory
56 corrupt. Generally, this option is useful for testing but should
57 not be used on a production installation. This option has no
58 effect when using --check.
62 Enable progress reporting. Turning this on will deliver a
63 progress report while checking or enabling checksums.
66 When set to fsync, which is the default, pg_checksums will
67 recursively open and synchronize all files in the data
68 directory. The search for files will follow symbolic links for
69 the WAL directory and each configured tablespace.
71 On Linux, syncfs may be used instead to ask the operating system
72 to synchronize the whole file systems that contain the data
73 directory, the WAL files, and each tablespace. See
74 recovery_init_sync_method for information about the caveats to
75 be aware of when using syncfs.
77 This option has no effect when --no-sync is used.
81 Enable verbose output. Lists all checked files.
85 Print the pg_checksums version and exit.
89 Show help about pg_checksums command line arguments, and exit.
94 Specifies the directory where the database cluster is stored;
95 can be overridden using the -D option.
98 Specifies whether to use color in diagnostic messages. Possible
99 values are always, auto and never.
103 Enabling checksums in a large cluster can potentially take a long time.
104 During this operation, the cluster or other programs that write to the
105 data directory must not be started or else data loss may occur.
107 When using a replication setup with tools which perform direct copies
108 of relation file blocks (for example pg_rewind), enabling or disabling
109 checksums can lead to page corruptions in the shape of incorrect
110 checksums if the operation is not done consistently across all nodes.
111 When enabling or disabling checksums in a replication setup, it is thus
112 recommended to stop all the clusters before switching them all
113 consistently. Destroying all standbys, performing the operation on the
114 primary and finally recreating the standbys from scratch is also safe.
116 If pg_checksums is aborted or killed while enabling or disabling
117 checksums, the cluster's data checksum configuration remains unchanged,
118 and pg_checksums can be re-run to perform the same operation.