Validating backups
In this recipe, we will use the data checksum feature to detect data corruption caused by I/O malfunctioning in advance.
It is important to discover such problems as soon as possible. For instance, we want a chance to recover lost data from one of our older backups, or we may want to stop data errors before they spread to the rest of the database when new data depends on existing data.
Getting ready
This feature is disabled by default, since it results in some overhead; it can be enabled when the cluster is initialized by using the --data-checksums
option of the initdb
utility, or on an existing cluster, with pg_checksum --enable
.
Also, before trying this recipe, you should be familiar with how to take backups and how to restore them afterward, which are the subjects of most of this chapter.
How to do it…
First, check whether data checksums are enabled:
postgres=# SHOW data_checksums ; data_checksums...