5

What's the best approach for backing up a Postgres on Kubernetes?

My first guess would have been to create a master-slave architecture with enabling replication. Doing an initial pg_basebackup and then fetching the WAL-logs. Once in a month I'd have scheduled another pg_basebackup with a cron, however containerized environemnts don't like cron daemons (no systemd available). How do you schedule base backups?

3

1 Answer 1

11

The best approach is to use the Kubernetes Cronjob resource:

You can use a CronJob to run Jobs on a time-based schedule. These automated jobs run like Cron tasks on a Linux or UNIX system.

Cron jobs are useful for creating periodic and recurring tasks, like running backups or sending emails.

You basically need to create a custom Linux image to run in your container jobs. This image will need a Postgres Client (so you can connect to your database with psql, pg_dump or pg_basebackup); and the credentials that can be configured as a secret.

You may want to upload the backup to external storage, so you can install and use awscli for AWS S3, gsutil for Google Cloud Storage, etc...

Here is some references:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.