Reputation: 1967
I have a kubernetes cluster, with a pod running the postgres database, so in Docker. Obviously, I have the data mounted on the host.
I would like to setup Barman to have a backup solution for the DB.
I read the documentation about barman. According to the Design and architecture section of http://docs.pgbarman.org/release/2.0/, I would like to go with the following architecture, because I have a large database and incremental backup is in our requirements. This is not possible with streaming backup strategy (Scenario 1: Backup via streaming protocol), even if they said it's better for Docker environments
My question is how can I setup this when postgres is running in Docker ? Because ofthe files that are mounted on the host, can I just ssh on the host to proceed to the backup ?
Thanks for the answer
Upvotes: 6
Views: 4116
Reputation: 1290
4 years have passed and many changes have occurred. I think it's worth mentioning what I consider is the best solution at the moment (and was not freely available at the time): CloudNativePg.
CloudNativePg is an open-source PostgreSQL operator for Kubernetes. It's designed to deploy and manage PostgreSQL clusters on Kubernetes in a cloud-native way. Here are some key advantages:
When you configure the cluster, you decide how many instances you want(primary/secondary+), when and where to save the backup. I personally use S3 for that, but you may use snapshots as well.
Upvotes: 0
Reputation: 746
You can't ssh to the host to proceed since it has to be initiated & coordinated by the PostgreSQL server running in the container.
You can however setup passwordless ssh connectivity (with ssh keys) along with streaming connectivity between PostgreSQL & Barman containers and implement the stated architecture.
This entails building & running a PostgreSQL container with ssh server & rsync along with barman.
There are many versions of implementations out there that have done it, but if you wanted to do something from the scratch & keep the image simple, please take a look at the implementation of the above shared in the below git repo,
https://github.com/softwarebrahma/PostgreSQL-Disaster-Recovery-With-Barman
Thanks
Upvotes: 5