Postgresql. Real-time copy of a database to another disk on the same server

postgresql

How to make a real-time copy of the database to another disk?

My database is very small, but WAL-logs are very large (many changes in time). I don't need 'Point-in-Time Recovery', I just need the latest version of the database. How to force a sql server to maintain an additional copy of the database to another disk in case the first disk lost data (hardware failure)?

Best Answer

If the first database "loses data", it's liable to tell the second database to "lose data to match me". (Depends on exactly what you mean by "lose data".) So reduce the chances of your database losing data due to a single disk failure by storing the database on an array: RAID 1, RAID 5, RAID 6, or RAID 10. I recommend RAID 6.

It's not clear whether you've read the docs for PostgreSQL's High Availability, Load Balancing, and Replication. Streaming replication is probably worth looking at.

To mitigate the risk of "losing data", you need to be precise about losing data means. Mitigating the risk of disk failure is different than mitigating the risk of an application deleting data by accident.