From 4d48b8355d179563fac7261835e23c814acb9212 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Mon, 22 Jan 2024 21:55:48 +0100 Subject: [PATCH] Create restic backup cronjob --- apps/gitea/restic-backup-cj.yaml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 apps/gitea/restic-backup-cj.yaml diff --git a/apps/gitea/restic-backup-cj.yaml b/apps/gitea/restic-backup-cj.yaml new file mode 100644 index 0000000..fe75a89 --- /dev/null +++ b/apps/gitea/restic-backup-cj.yaml @@ -0,0 +1,53 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: restic-backup-cronjob + namespace: gitea +spec: + schedule: "0 2 * * *" # Cron expression for running daily at 2 AM + jobTemplate: + spec: + template: + spec: + volumes: + - name: gitea-data + emptyDir: {} + - name: backup-vol + emptyDir: {} + - name: postgres-data + persistentVolumeClaim: + claimName: data-gitea-postgresql-0 + + initContainers: + - name: postgres-dump-init + image: bitnami/postgresql:15.3.0-debian-11-r24 + command: ["/bin/sh", "-c"] + args: ["pg_dump -U gitea gitea -Fc > /backup-vol/postgres_backup.dump"] + env: + - name: PGPASSWORD + value: "" + volumeMounts: + - name: backup-vol + mountPath: /backup-vol + - name: postgres-data + mountPath: /bitnami/postgresql/data + + - name: gitea-dump-init + image: gitea-image:tag + command: ["/bin/sh", "-c"] + args: ["cp /path/to/backup.zip /backup-vol/backup.zip"] + volumeMounts: + - name: gitea-data + mountPath: /path/to/backup + - name: backup-vol + mountPath: /backup-vol + + containers: + - name: restic-container + image: git.namesny.com/cluster/restic:0.16.2-r0 + command: ["/bin/bash", "/path/to/backup.sh"] + volumeMounts: + - name: backup-vol + mountPath: /backup-vol + + restartPolicy: OnFailure