A database backup is a consistent, restorable copy of the data, metadata and transaction history of a database, stored separately from the live system so that the database can be rebuilt after hardware failure, human error, corruption or attack. In databases, backup is only half of the discipline known as Backup & recovery: a copy has value only if it can be restored within an agreed time to an agreed point in time.
Unlike a simple file copy, a proper database backup must respect transactional consistency. A database engine constantly modifies pages in memory and on disk, so copying data files while the server writes to them usually produces an unusable image unless the engine coordinates the process or the copy is paired with the matching transaction logs.
How a database backup preserves consistency
A database backup preserves consistency by capturing either a logical view of committed data at one moment or a physical image of data files together with the log records needed to repair them. Logical tools such as pg_dump and mysqldump read the data through a transaction snapshot, so every table reflects the same instant. Physical tools such as pg_basebackup, Percona XtraBackup and RMAN copy data blocks while the server runs, and the engine later replays the write-ahead log or redo log to bring the copied blocks to a consistent state.
The log is therefore central to almost every serious backup strategy. Relational engines record each change in a sequential log before it reaches the data files, which allows crash recovery after a power loss. Backup systems reuse the same mechanism: by archiving the log continuously, an administrator can restore a base copy and then roll forward to any moment covered by the archive, which is the basis of point-in-time recovery.
The following table summarizes the main components that a complete backup set usually contains and why each one matters.
| Component | What it contains | Why it is needed |
|---|---|---|
| Base backup | Full copy of data files or logical export | Starting point for every restore |
| Log archive | WAL segments, binary logs or redo logs | Roll forward to a chosen moment |
| Metadata | Users, roles, configuration, schema | Rebuild a working server, not only tables |
| Catalog or manifest | List of files, checksums, timestamps | Verify completeness before restoring |
| Encryption keys | Keys for encrypted backups or tablespaces | Without them the copy is unreadable |
Types of database backup
Database backups are classified by what is copied, how much is copied and whether the database stays online. These dimensions combine freely: a hot physical incremental backup and a cold logical full backup are both valid designs. The choice determines backup duration, storage cost and, above all, restore speed.
| Type | How it works | Main advantage | Main drawback |
|---|---|---|---|
| Full backup | Copies the entire database | Simplest, self-contained restore | Slow and large for big databases |
| Differential backup | Copies changes since the last full backup | Restore needs only two sets | Grows daily until the next full |
| Incremental backup | Copies changes since the last backup of any kind | Smallest and fastest to take | Restore must apply a long chain |
| Transaction log backup | Copies log records since the previous log backup | Enables point-in-time recovery | Useless without a valid base |
| Logical backup | Exports rows and schema as SQL or a portable format | Portable across versions and platforms | Slow restore with index rebuilds |
| Physical backup | Copies data blocks or files | Fast restore of large databases | Tied to engine version and layout |
Availability is the second axis. A hot backup runs while the database accepts reads and writes, a warm backup allows reads only, and a cold backup requires a clean shutdown. Hot backups are standard in production because few systems can accept nightly planned downtime.
Backup compared with related protection methods
A database backup is not the same as replication, a storage snapshot or high availability, although all of them protect data. The decisive difference is isolation in time and space: a backup keeps older versions on separate storage, while replication faithfully copies every change, including an accidental DROP TABLE or ransomware encryption, to the replica within seconds.
| Technique | Protects against | Does not protect against |
|---|---|---|
| Database backup | Deletion, corruption, ransomware, site loss | Downtime during a long restore |
| Replication | Server or node failure | Logical errors that replicate instantly |
| Database snapshot | Recent mistakes on the same system | Loss of the underlying storage array |
| Log shipping | Primary site failure with some lag | Errors replayed before detection |
| Crash recovery | Power loss and process crashes | Lost or damaged data files |
Features such as Oracle Flashback or delayed replicas shorten recovery from human error, yet they complement rather than replace an off-system backup chain.
Designing a backup strategy around RPO and RTO
A backup strategy is designed backward from two business targets. The recovery point objective (RPO) states how much recent data the organization can afford to lose, and the recovery time objective (RTO) states how long the service may stay unavailable during a restore. A daily full backup alone gives an RPO of up to 24 hours; adding continuous log archiving can reduce it to seconds or minutes.
The decision table below shows typical starting configurations; real designs also weigh database size, change rate, network bandwidth and regulatory duties.
| Situation | Recommended approach | Reason |
|---|---|---|
| Small database, tolerant RPO | Nightly logical dump | Simple, portable, cheap to store |
| Large OLTP system, strict RPO | Weekly physical full, daily incremental, continuous log archiving | Minimizes data loss and backup window |
| Strict RTO for multi-terabyte data | Physical backups plus standby replica | Restoring from scratch would take too long |
| Ransomware exposure | Immutable, offline or air-gapped copies | Attackers often delete reachable backups |
| Legal retention duties | Defined backup retention policy with tiered storage | Keeps required history at controlled cost |
Many teams follow the 3-2-1 rule: at least three copies of the data, on two different media types, with one copy off-site. Current practice often extends it with one immutable copy and zero unverified backups, because a backup that has never been restored is an assumption rather than a safeguard.
Common failures and how to prevent them
Most backup failures are discovered only during an emergency restore, which is the worst moment to learn that the strategy does not work. Experienced administrators treat restore testing as part of the backup process, measuring actual restore duration against the RTO and checking data integrity after each test.
- Broken log chains: a missing WAL segment or binary log makes point-in-time recovery impossible beyond the gap; monitor archiving continuously.
- Copying live files without coordination: a plain file copy of a running server is usually inconsistent; use engine-aware tools.
- Lost encryption keys: encrypted backups without their keys cannot be restored at all.
- Silent corruption: copying corrupted pages preserves the corruption; enable checksums and validate backups.
- Untested restores: procedures, credentials and tooling drift until nobody can perform a restore under pressure.
Stripped to the essentials
A database backup is a safety copy of everything a database knows, kept somewhere else so it survives when the original breaks. If someone deletes the wrong records, a disk dies or malware scrambles the files, the copy lets the team put the data back.
Think of it like saving versions of an important document, plus a diary of every edit made since the last save. With the saved version and the diary, the document can be rebuilt as it looked at almost any moment. The key point is simple: a backup only counts if it can actually be restored, so good teams practice restoring regularly.
Where it is applied
An online retailer runs a 2 TB PostgreSQL database that handles orders around the clock. The team takes a physical base backup with pgBackRest every Sunday, incremental backups every night and continuous WAL archiving to object storage in a second region, with a copy locked against deletion for 30 days.
On a Wednesday at 14:05, a faulty deployment script deletes the shipping addresses of recent customers. The replica receives the same deletion within a second, so it cannot help. The administrators restore the latest base and incremental backups to a new server and replay the archived log up to 14:04:30, just before the script ran.
The restored data is ready in about two hours, within the agreed recovery time, and the missing addresses are copied back into production. The team loses no orders, because the regular quarterly restore drills had already confirmed that the procedure and timings were reliable.