“Was the order saved?” is a reasonable question after a power failure. It is also several questions wearing one coat: what committed, what reached durable storage, and whether that storage honored the database’s flush request. A PostgreSQL table file by itself does not answer all three.
PostgreSQL uses a write-ahead log, or WAL, to record changes before the corresponding changed data pages are written to their files. Its WAL introduction explains how this ordering enables the server to replay relevant records after a crash. Under appropriate durability settings and reliable storage, a commit can be acknowledged without forcing every modified table page to disk at that instant.
That design makes many small transactions practical. It also creates a distinction worth keeping straight: the live server’s crash-recovery log, an archived stream of log records, a base backup, and a tested point-in-time restore are related pieces—not four names for the same backup.
The order that makes replay possible
A database page can be changed in memory before the updated page is written to its on-disk data file. PostgreSQL’s rule is that the relevant WAL records must be flushed before that changed data page is written. If the server fails before all changed pages are present in the files, recovery can use the log to redo changes that need to be applied. The log gives the server an ordered account of changes it can use to bring files back into a consistent state.
Consider a fictional transaction that reduces available inventory and records an order. The transaction is acknowledged as committed under the system’s configured durability behavior. A power loss follows before every affected data page has been written. If the required WAL is durable and the underlying system honors its guarantees, PostgreSQL can replay the necessary records during restart. The explanation is about the database’s committed state; whether the customer saw the confirmation or whether a separate email was sent are other events.
This is not permission to treat hardware as infallible. PostgreSQL’s WAL reliability guidance discusses operating-system and storage behavior. Devices, caches, virtualized layers and configuration choices can affect whether a request to flush data is actually durable. A database guarantee is built on assumptions about the whole path, not merely the word “committed” in a log line.
Why the checkpoint matters
A checkpoint is a recovery landmark. PostgreSQL ensures that the necessary state of data files is on disk according to its checkpoint process, so recovery has a place from which to begin. The server’s WAL configuration documentation describes checkpoints and the tradeoff between checkpoint activity and recovery work.
It is tempting to turn that into a single dial: “more checkpoints mean safer” or “fewer checkpoints mean faster.” Neither statement is a complete operational decision. Frequent checkpointing can increase write activity; a longer interval may leave more log to process after a crash. The right behavior depends on workload, storage capacity, recovery objectives and current PostgreSQL settings. Measure the effects in an appropriate environment before changing production configuration.
Do not confuse the checkpoint time with the time of the last committed transaction. A transaction committed after a checkpoint may still be recoverable from durable WAL. Equally, a timestamp on a monitoring dashboard does not prove that a separate backup or archive contains every record needed for a later restore. Each claim requires its own evidence.
A log on the server is not a second copy
The live cluster maintains WAL for normal operation and crash safety. Older segments are not necessarily kept forever: PostgreSQL can recycle or remove segments when they are no longer needed under the relevant configuration. If the only disk holding both the database and its local WAL is lost, the fact that the log once existed on that disk does not restore the system.
Continuous archiving is a separate design. PostgreSQL’s archiving and point-in-time recovery guide describes combining a base backup with a continuous sequence of archived WAL. Recovery can replay the necessary records and, when properly configured and supported, stop at a chosen recovery target. A gap in the required sequence can prevent reaching a later target. A folder containing a few log files is not proof of continuity.
Suppose a fictional business takes a valid base backup at midnight and archives the required WAL afterward. At 14:00 an operator accidentally deletes an important set of rows. A recovery team might restore to an isolated location and choose a target just before the mistake, then inspect the recovered data. The precise target, available records, timeline, backup method and application dependencies determine what is actually possible. “We have WAL” is only the beginning of that investigation.
A point-in-time restore also raises a business question: what should happen to legitimate orders created after the chosen target? Replacing the entire production database with the older state could discard those later changes. Often the team needs to compare and selectively recover information using a reviewed procedure. Never assume the technically earliest route is the least disruptive one.
Read the recovery evidence in order
Before a real incident, write down which backup belongs to which cluster, its completion status, where its bytes live, and the earliest and latest WAL records available for that backup chain. A backup job’s success notification can be useful, but it does not show that the files can be retrieved, that every required archive segment exists, or that the restored database can start.
Then run an isolated restore test. Confirm the base backup and required log sequence, perform recovery using the documented procedure, and inspect a small set of representative business records. Record the target and the actual recovered point. Verify application access through appropriate test credentials and check whether the result supports the business task—not just whether a server process is running.
For an illustrative timing exercise, suppose a team begins retrieving a backup at 09:00, has the database started at 09:35, and confirms the key application checks at 09:55. The technical start took 35 minutes; the demonstrated route to a usable service took 55 minutes. Neither number promises the next incident will be identical. It helps identify where retrieval, replay, startup and business validation consume time.
The test should also identify who can access the backup and archive during an outage. Separate storage permissions, encryption-key access, network routes and an intact recovery procedure are all dependencies. A backup stored in a different location is valuable only if the people responsible can retrieve and use it when the normal system is unavailable.
A restore test can reveal a second clock: how far back the latest recoverable point is. Suppose an incident is discovered at 14:00, but the most recent complete archived sequence available for the chosen backup reaches 13:40. Under those simplified facts, the archive alone has a 20-minute gap between its latest recoverable point and discovery. The exact outcome still depends on the backup chain and any other valid sources. Record that interval separately from the 55-minute restoration time in the earlier example; recovery-point and recovery-time objectives ask different questions.
Do not infer a complete archive from a file count. The files must belong to the right cluster and recovery history, cover the necessary interval without a gap, and remain accessible alongside the matching base backup. PostgreSQL recovery timelines can branch after a point-in-time restore, so retain the relevant history and follow the documentation for the actual recovery. A test performed months ago also cannot establish that today’s archive job, credentials or key access still work.
WAL and other safeguards solve different problems
WAL supports database recovery and, when archived with a suitable backup, can support point-in-time recovery. It does not prevent an authorized user from committing an incorrect update. It does not ensure a replica is fully current. It does not capture a third-party payment provider’s state or a file stored outside the database. An application-level recovery plan must include the systems and side effects that belong to the same business process.
Nor does keeping a server running prove that an archive is healthy. Monitor backup completion, archive failures, available capacity and restore-test results with named owners. A disk filling because logs cannot be archived is an operational issue; deleting unknown segments by hand can make the recovery situation worse. Investigate using the current documentation and a reviewed procedure rather than treating a full folder as an invitation to remove files.
Our backup-restore guide covers the broader test. The PostgreSQL-specific lesson is that the path from a committed order to a recoverable business record has several links: durable WAL, an appropriate backup and archive, access to their bytes, and a tested decision about what to recover. A successful checkpoint is useful evidence for one part of that path, not a substitute for the rest.
Explore Infinite Upside
For Vijay Sheth’s personal accounts, read Infinite Upside: Building Wealth With Room to Live, published by Sheth Capital, Inc.
Explore a related guide
Why Does PostgreSQL Need Vacuuming?