Hot Backup vs Cold Backup: What is the Difference?
Learn the difference between hot and cold database backups, how each keeps data consistent, and when to use them.
Expected Interview Answer
A hot backup is taken while the database stays online and serving reads and writes, using transaction-consistent snapshots or log coordination, whereas a cold backup requires shutting the database down first so the files are copied while completely static.
Hot backups rely on the database engine coordinating the copy with its transaction log so the result is consistent even though data is changing underneath it, which keeps the system available but adds some CPU and I/O overhead during the backup window. Cold backups avoid that complexity entirely by taking the database offline, guaranteeing a perfectly consistent file-level copy with zero risk of capturing an in-flight write, at the cost of planned downtime for every backup. Most production systems that cannot tolerate downtime use hot backups combined with log shipping, reserving cold backups for systems with a maintenance window or for creating a guaranteed-consistent baseline.
- Hot backups avoid downtime, keeping the database available to users
- Cold backups guarantee a simple, perfectly consistent snapshot
- Hot backups suit systems requiring continuous availability
- Cold backups suit systems with a defined maintenance window
AI Mentor Explanation
A hot backup is like a broadcaster recording match footage while play continues uninterrupted, using timestamps to keep the recording consistent with the live scoreboard even as things keep happening. A cold backup is like pausing the match entirely to walk the pitch and photograph every marking with nothing moving, guaranteeing a perfectly clean shot but stopping play for everyone. Teams that cannot afford to halt the match use the hot approach, while a groundskeeper doing a full pitch audit prefers the cold approach.
Step-by-Step Explanation
Step 1
Decide availability requirements
Determine whether the system can tolerate a maintenance window or must stay online continuously.
Step 2
For hot backups, coordinate with the transaction log
The engine takes a consistent snapshot while writes continue, using log markers to define a valid cut point.
Step 3
For cold backups, shut the database down
Stop the database process so no writes occur, then copy the raw data files directly.
Step 4
Validate the resulting backup
Restore-test either type to confirm the copy is complete and internally consistent.
What Interviewer Expects
- Clear distinction between online (hot) and offline (cold) backup approaches
- Understanding that hot backups rely on transaction log coordination for consistency
- Awareness of the availability vs simplicity trade-off between the two
- A sense of when each approach is appropriate for a given system
Common Mistakes
- Assuming a hot backup can be a raw file copy without log coordination
- Believing cold backups are always safer without acknowledging the downtime cost
- Confusing hot/cold backups with full/incremental backup strategy
- Not mentioning that most production systems favor hot backups for availability
Best Answer (HR Friendly)
โA hot backup is taken while the database keeps running and serving users, using the transaction log to make sure the copy is still consistent. A cold backup requires shutting the database down first so the files are copied while nothing is changing, which is simpler and guaranteed consistent but causes downtime. Most production systems prefer hot backups to avoid interrupting service, while cold backups suit systems that have a scheduled maintenance window.โ
Code Example
-- Hot backup: database stays online, engine coordinates a
-- consistent snapshot using WAL markers
SELECT pg_start_backup('hot_backup_2026_07_18');
-- ... file-system level copy of the data directory happens here ...
SELECT pg_stop_backup();
-- Cold backup: database must be stopped first
-- pg_ctl stop -D /var/lib/postgresql/data
-- cp -R /var/lib/postgresql/data /backups/cold_2026_07_18
-- pg_ctl start -D /var/lib/postgresql/dataFollow-up Questions
- How does a hot backup guarantee consistency despite ongoing writes?
- When would a cold backup still be preferred over a hot backup?
- How does hot backup overhead affect production performance?
- How do hot and cold backups relate to full and incremental strategies?
MCQ Practice
1. A hot backup is taken:
Hot backups run while the database stays available, using log coordination to remain consistent despite ongoing writes.
2. What guarantees consistency in a hot backup?
The database engine uses transaction log markers to define a consistent point despite concurrent writes during a hot backup.
3. The main trade-off of a cold backup compared to a hot backup is:
Cold backups guarantee a simple, fully consistent copy but require shutting the database down, causing planned downtime.
Flash Cards
What is a hot backup? โ A backup taken while the database stays online, using transaction log coordination for consistency.
What is a cold backup? โ A backup taken after shutting the database down, copying static files with guaranteed consistency.
Main advantage of hot backups? โ No downtime โ the database remains available during the backup.
Main advantage of cold backups? โ Simplicity and guaranteed consistency since nothing is changing during the copy.