pg_integrity_check
pg_integrity_check — calculate and validate checksums for controlled files (certified edition only)
Synopsis
pg_integrity_check [connection-option...] [ -s | --system ] [ -u | --user ] [ -c | --catalog ] [ -o | --output ] [ -l filename | --log=filename ] [ --syslog ] [ -D datadir ] [ -C filename ] [ -v | --verbose ] [ -? | --help ]
Description
pg_integrity_check is a utility provided with Postgres Pro Standard that can calculate and validate checksums for the objects you would like to control. When running pg_integrity_check, you must specify at least one of the options that define the type of the controlled objects: -s, -u, or -c for read-only files, additional files, or system catalog tables, respectively.
If you use the -o option, pg_integrity_check calculates checksums and writes them into configuration files under the share/security/ directory. You must have write access to the corresponding files to perform this command. You cannot use the -o option together with the -s option, since a checksum for read-only files cannot be overwritten.
If you omit the -o option, pg_integrity_check compares the calculated checksums with the corresponding checksums in the configuration files. If the checksums differ for any of the controlled objects, pg_integrity_check displays a message indicating the difference.
For details on using pg_integrity_check, see Section 31.2.
Options
connection-optionsStandard options for connecting to a database:
-d,-h,-p,-U. You must specify-dand-Uoptions when validating checksums for catalog tables with the-coption. For detailed description of connection options, see psql.-s--systemValidate checksums for read-only files. Checksums for read-only files control both file contents and file attributes.
-u--userValidate checksums for additional files. Checksums for additional files control both file contents and file attributes.
-c--catalogValidate checksums for system catalog tables. For the
-coption to work correctly, you must also specify connection parameters for the database. The database server must be started and accept connections.-o--outputRecalculate checksums and write it into a file.
-lfilename--log=filenameWrite checksum validation results into a log file.
--syslogWrite checksum validation results into the syslog.
-DdatadirData directory of the database cluster. This option is required to define the filenames for the generated configuration files when using
-uoption.-CfilenameThe absolute path to the configuration file used for integrity checks of system catalog tables of the selected database. If used with the
-ooption,pg_integrity_checkwrites into the specified file. If no other option is used,pg_integrity_checkchecks data against the specified file.-v--verbosePrint debugging information, including checksum values.
-?--helpPrint command-line help.
Return Values
0 — checksums are calculated or validated successfully.
1 — an error occurred during the initial checksum calculation for read-only files.
2 — checksum validation revealed changes in one or more of the controlled objects.
3 — an unexpected error occurred during checksum validation.
Examples
Compute checksums for additional files and write them into the share/security/_var_lib_pgpro_std-15_data.user.conf configuration file:
pg_integrity_check -u -o -D /var/lib/pgpro/std-15/data
Check integrity of all controlled objects in the postgres database on behalf of the postgres user:
pg_integrity_check -s -u -c -D /var/lib/pgpro/std-15/data -d postgres -h localhost -p 5432 -U postgres