DAT-27Recommended
Keep point-in-time recovery for busy databases
Where losing a day of writes is not acceptable, keep the database's change log, so you can restore to any moment.
How to do it
In PostgreSQL, archive the write-ahead log with a tool such as pgBackRest or WAL-G. In MySQL, keep the binary log. Managed databases offer it as a setting. It also undoes mistakes, such as a bad DELETE, by restoring to the minute before. Choose it from the data loss limit in Set recovery targets.
How to check
Restore a staging copy to a chosen time 10 minutes ago. A row written 5 minutes ago is missing, and one written 15 minutes ago is there.
Sources
Related rules
- OPS-44 Set recovery targets in Operations and observability
- STK-28 Use PostgreSQL for the main database in Software choices
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/backups-and-recovery/point-in-time-recovery">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.