Postgres database replication in nix

I’m wonder how to best replicate a postgres db.

There are many options available, from using postgres replication tools, to doing more funky zfs ‘sends’ between machines.

Anyone out there doing this, how do you replicate state , because with a legacy database you can’t really avoid it!!

Hi,

if you just need replication than I think you’re fine using what PostgreSQL provides already. Imho, there is no descriptive approach to set this up on NixOS, but anyhow it’s simple.

I was in need for a HA setup for PostgreSQL for some time. I read you post and was hoping that others have solutions based on NixOS. Unfortunately no-one replied. I played a little with streaming replication but found that for my use-case I need more than that. My research led me again to Patroni, which I already know from the Postgres Operator (k8s) which is also based on Patroni.

Because I did not found anything usable so far; I created my own NixOS modules:

Both are Nix flakes with NixOS modules included (see their respective README for details).

Contributions are welcome and please keep in mind that these projects are in a early stage.

6 Likes

Thank you so much for contributing, i’ll have a play with this when i get a moment.

Great use of flakes…!!!

1 Like