Point in time recovery (Intermediate)
PostgreSQL also has the ability to restore the database to any point in history following the previous backup. This is called point in time recovery (PITR). It does this by keeping files called transaction logs. So long as we store these transaction logs, we can use them to restore to any date they contain.
Getting ready
Please refer to the Getting a basic export (Simple) recipe to bootstrap our database. Before we start the database to create the sample
database, we need to change a couple of settings in postgresql.conf
. For this, we will need a path in /archive
to store transaction logs, which can be used by the following configuration settings:
wal_level = archive archive_mode = on archive_command = 'test ...
Get Instant PostgreSQL Backup and Restore How-to now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.