k8s-db-backup

by DebjotiMallick

Helm chartv0.0.5App 0.0.5Verified publisher

A Helm chart for kubernetes database backup

About this chart

k8s-db-backup Helm Chart

Helm chart for deploying a Kubernetes database backup solution supporting PostgreSQL, MySQL, and MongoDB with S3-compatible storage.

Introduction

The k8s-db-backup Helm chart provides a simple way to deploy a backup solution for your Kubernetes databases. It supports various database types, including PostgreSQL, MySQL, and MongoDB, and allows you to back up your data to S3-compatible storage.

Prerequisites

  • Kubernetes 1.23+
  • Helm 3.8+
  • PV provisioner support in the underlying infrastructure
  • S3-compatible storage account (AWS S3, Cloudflare R2, MinIO, etc.)

Adding the Helm repository

To use the chart, first add the Helm repository:

helm repo add debjoti https://charts.debjotimallick.store/

Installing the chart

To install the chart with the release name my-backups, first modify the values.yaml file to set your S3 credentials and database instances to back up. Then run the following command:

helm install my-backups -f values.yaml debjoti/k8s-db-backup

Uninstalling the chart

To uninstall/delete the my-backups deployment:

helm uninstall my-backups

This will delete all the Kubernetes components associated with the chart and delete the release.

Configurations

ParameterDescriptionDefault
s3.endpointS3-compatible endpoint URL""
s3.accessKeyS3 access key""
s3.secretKeyS3 secret key""
mongodb.enabledEnable MongoDB backupsfalse
mongodb.scheduleCron schedule for MongoDB backups""
mongodb.bucketNameS3 bucket name for MongoDB backups""
mongodb.instancesList of MongoDB instances to back up[]
mongodb.instances[].hostnameMongoDB instance hostname or service name""
mongodb.instances[].namespaceNamespace of the MongoDB instance""
mongodb.instances[].portMongoDB instance port (Optional)27017
postgres.enabledEnable PostgreSQL backupstrue
postgres.scheduleCron schedule for PostgreSQL backups""
postgres.bucketNameS3 bucket name for PostgreSQL backups""
postgres.instancesList of PostgreSQL instances to back up[]
postgres.instances[].hostnamePostgreSQL instance hostname or service name""
postgres.instances[].namespaceNamespace of the PostgreSQL instance""
postgres.instances[].portPostgreSQL instance port (Optional)5432
postgres.instances[].databasesList of databases to backup (* for all databases)["*"]
mysql.enabledEnable MySQL backupstrue
mysql.scheduleCron schedule for MySQL backups""
mysql.bucketNameS3 bucket name for MySQL backups""
mysql.instancesList of MySQL instances to back up[]
mysql.instances[].hostnameMySQL instance hostname or service name""
mysql.instances[].namespaceNamespace of the MySQL instance""
mysql.instances[].portMySQL instance port (Optional)3306
mysql.instances[].databasesList of databases to backup (* for all databases)["*"]
persistence.storageClassStorage class for PVC""
persistence.sizeSize of PVC for storing backups10Gi

Quick start examples

  • PostgreSQL (enable backups for all DBs):
postgresql:
  enabled: true
  schedule: "0 2 * * *"
  bucketName: "my-postgres-backups"
  instances:
    - hostname: postgresql-main
      namespace: prod
      databases: ["*"]
      port: 5432
  • MySQL (enable backups for specific DBs):
mysql:
  enabled: true
  schedule: "0 3 * * *"
  bucketName: "my-mysql-backups"
  instances:
    - hostname: mysql-main
      namespace: prod
      databases: ["db1", "db2"]
      port: 3306

Restore procedures (high-level)

  1. Locate backup object in S3 (bucket and prefix per job).
  2. Download backup file to a restore host or a restore pod.
  3. For PostgreSQL: use pg_restore/psql to restore the dump.
  4. For MySQL: use mysql client to import the SQL file.
  5. For MongoDB: use mongorestore against the target instance.

Deploy k8s-db-backup with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has k8s-db-backup on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartk8s-db-backup is pinned at v0.0.5 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply