Get the latest tech news
Using short lived Postgres servers for testing
Database servers are usually long-lived, and important parts of the infrastructure that we build on. We rarely set them up from scratch, because we have to take such good care of them over time. I think this causes a lot of people to think that setting up a database server is some mysteriously difficult ordeal. To be clear, that’s actually true, if you need high availability and a solid recovery point objective.
The pg_basebackup command takes a binary snapshot of the-D directory of the stable instance, and replays any transactions that happened during the backup. You’ll need to create a new pod with an initContainer that runs pg_basebackup to set up the data directory, then start the postgres instance in the main container. In the weekend, I remembered this pattern that I’ve used many times before, and I thought maybe eugene trace can just bring its own postgres instance to the party.
Or read this on Hacker News