Setup barman backup when Posgres is running in Docker
Asked Answered
F

2

6

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

enter image description here

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

Fennelly answered 20/7, 2020 at 8:37 Comment(0)
E
5

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

Eventuate answered 4/8, 2020 at 2:59 Comment(0)
I
0

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:

  • Native Kubernetes integration: It leverages Kubernetes primitives for high availability, scalability, and self-healing.
  • Automated failover: Ensures high availability with automatic promotion of replicas to primary.
  • Declarative configuration: Use Kubernetes custom resources to define your PostgreSQL clusters.
  • Backup and recovery: Built-in support for point-in-time recovery and integration with object storage.
  • Monitoring: Prometheus integration for comprehensive monitoring.
  • Rolling updates: Perform updates with minimal downtime.

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.

Insufficiency answered 3/9, 2024 at 15:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.