From 84b703efa05e7bee3ad61f4a78c52b7c10bd4048 Mon Sep 17 00:00:00 2001 From: Adrien Beaudouin Date: Sun, 10 Sep 2023 12:59:36 +0200 Subject: [PATCH] add if exists --- content/posts/13-a-beautiful-gitops-day-3/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/posts/13-a-beautiful-gitops-day-3/index.md b/content/posts/13-a-beautiful-gitops-day-3/index.md index 7214b0c..037cf9f 100644 --- a/content/posts/13-a-beautiful-gitops-day-3/index.md +++ b/content/posts/13-a-beautiful-gitops-day-3/index.md @@ -759,7 +759,7 @@ Configure this variable according to your needs. If you need some regular dump of your database without requiring a dedicated Kubernetes `CronJob`, you can simply use following crontab line on control plane node: ```sh -0 */8 * * * root /usr/local/bin/k3s kubectl exec sts/postgresql-primary -n postgres -- /bin/sh -c 'PGUSER="okami" PGPASSWORD="$POSTGRES_PASSWORD" pg_dumpall -c | gzip > /bitnami/postgresql/dump_$(date "+\%H")h.sql.gz' +0 */8 * * * root /usr/local/bin/k3s kubectl exec sts/postgresql-primary -n postgres -- /bin/sh -c 'PGUSER="okami" PGPASSWORD="$POSTGRES_PASSWORD" pg_dumpall -c --if-exists | gzip > /bitnami/postgresql/dump_$(date "+\%H")h.sql.gz' ``` It will generate 3 daily dumps, one every 8 hours, on the same primary db volume, allowing easy `psql` restore from the same container.