60 lines
1.7 KiB
YAML
60 lines
1.7 KiB
YAML
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:
|
|
|
|
serviceAccountName: restic-admin-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
|
|
configMap:
|
|
name: restic-backup-script
|
|
- name: repo-env
|
|
secret:
|
|
secretName: repo-env-secret
|
|
|
|
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 > /pg_backup/postgres_backup.dump"]
|
|
volumeMounts:
|
|
- name: 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/bash", "/app/restic-backup.sh"]
|
|
volumeMounts:
|
|
- name: backup-vol
|
|
mountPath: /pg_backup
|
|
- name: gitea-data
|
|
mountPath: /gitea
|
|
- name: backup-script
|
|
mountPath: /app
|
|
subpath: restic-backup.sh
|
|
- name: repo-env
|
|
mountPath: /app
|
|
subpath: repo.env
|
|
|
|
restartPolicy: OnFailure
|