The PostgreSQL administration field guideField notes · Runbooks · Free certification

Section 1 of 3 · 6 minutes

Choose a precise recovery target

Your goal

What you will be able to do

Select a timestamp, transaction, restore point, or WAL location just before the unwanted change.

Why this matters at work

The practical reason

An unclear target can replay the damaging change again or discard more good work than necessary.

Learn

The idea in plain English

Build a timeline from application logs, audit records, WAL evidence, and confirmed time zones. Choose the latest safe point before the damaging transaction.

Write the target and stop condition before starting recovery. Keep the original service unchanged while the isolated restore is inspected.

Remember these points

  • Use an exact target and time zone.
  • Stop before the unwanted transaction is replayed.
  • Restore into isolation before planning a cutover.

See it in SQL

Record the current transaction and WAL position

Create timeline evidence that can be connected to logs and restore targets.

SELECT
  clock_timestamp() AS measured_at,
  txid_current() AS current_transaction_id,
  pg_current_wal_lsn() AS current_wal_position;

This measurement does not identify the damaging transaction by itself. It provides a timestamped point that can be correlated with other records.

Keep time zones explicit when logs and database timestamps come from different systems.

What you should see

A timestamp, transaction identifier, and WAL position from the same session.

Useful words

Important terms

Recovery target
The exact point where WAL replay should stop during point-in-time recovery.

Quick check · Not graded

Check your understanding

Where should a point-in-time restore be performed first?

Choose one answer

Your progress is saved to your signed-in account.