apiVersion: batch/v1 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: serviceAccountName: restic-sa volumes: - name: gitea-data persistentVolumeClaim: claimName: gitea-shared-storage - name: postgres-data persistentVolumeClaim: claimName: data-gitea-postgresql-0 - name: postgres-backup-vol emptyDir: {} - name: backup-script-vol configMap: name: restic-backup-script initContainers: - name: postgres-dump-init image: bitnami/postgresql:15.3.0-debian-11-r24 command: ["/bin/sh", "-c"] args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /pg_backup/postgres_backup.dump"] env: - name: PGPASSWORD valueFrom: secretKeyRef: name: gitea-postgresql key: postgres-password volumeMounts: - name: postgres-backup-vol mountPath: /pg_backup - name: postgres-data mountPath: /bitnami/postgresql/data containers: - name: restic-container image: git.namesny.com/cluster/restic:latest imagePullPolicy: Always command: ["/bin/sh", "/app/restic-backup.sh"] envFrom: - secretRef: name: restic-secret volumeMounts: - name: postgres-backup-vol mountPath: /pg_backup - name: gitea-data mountPath: /gitea - name: backup-script-vol mountPath: /app restartPolicy: OnFailure