From 0fc7740ac3a513b86e0a03d28c8a3264a76cdda6 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Sun, 1 Dec 2024 23:20:02 +0100 Subject: [PATCH] feat(backups): Configure WAL and schedule backups --- manifests/database-backup.yaml | 10 ++++++++++ manifests/database-ondemande-backup.yaml | 8 ++++++++ manifests/database.yaml | 18 ++++++++++++++++++ manifests/kustomization.yaml | 1 + 4 files changed, 37 insertions(+) create mode 100644 manifests/database-backup.yaml create mode 100644 manifests/database-ondemande-backup.yaml diff --git a/manifests/database-backup.yaml b/manifests/database-backup.yaml new file mode 100644 index 0000000..a2d1ffd --- /dev/null +++ b/manifests/database-backup.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: gitea-db-backup + namespace: gitea +spec: + schedule: "0 0 * * *" + backupOwnerReference: self + cluster: + name: gitea-db diff --git a/manifests/database-ondemande-backup.yaml b/manifests/database-ondemande-backup.yaml new file mode 100644 index 0000000..f6bf36e --- /dev/null +++ b/manifests/database-ondemande-backup.yaml @@ -0,0 +1,8 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: gitea-db-ondemand-backup + namespace: gitea +spec: + cluster: + name: gitea-db diff --git a/manifests/database.yaml b/manifests/database.yaml index b498506..83a8af2 100644 --- a/manifests/database.yaml +++ b/manifests/database.yaml @@ -22,6 +22,24 @@ spec: pg_hba: - host all all all md5 + backup: + barmanObjectStore: + destinationPath: "s3://halis/cloudnativepg" + endpointURL: https://s3.halia.dev + s3Credentials: + accessKeyId: + name: s3-secret + key: AWS_ACCESS_KEY_ID + secretAccessKey: + name: s3-secret + key: AWS_SECRET_ACCESS_KEY + region: + name: s3-secret + key: AWS_REGION + wal: + compression: gzip + maxParallel: 8 + resources: requests: cpu: 100m diff --git a/manifests/kustomization.yaml b/manifests/kustomization.yaml index d1a652e..82cbaf3 100644 --- a/manifests/kustomization.yaml +++ b/manifests/kustomization.yaml @@ -5,6 +5,7 @@ resources: - namespace.yaml - secrets.yaml - database.yaml + - database-backup.yaml - service.yaml - servicemonitor.yaml - ingress.yaml