59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: restic-backup-cronjob
|
|
namespace: gitea
|
|
spec:
|
|
schedule: "0 3 * * *" # Cron expression for running daily at 2 AM
|
|
jobTemplate:
|
|
spec:
|
|
template:
|
|
spec:
|
|
|
|
serviceAccountName: restic-sa
|
|
hostname: restic-cronjob
|
|
|
|
volumes:
|
|
- name: gitea-data
|
|
persistentVolumeClaim:
|
|
claimName: gitea-shared-storage
|
|
- name: restic-backup-vol
|
|
persistentVolumeClaim:
|
|
claimName: restic-backup-vol
|
|
- name: backup-script-vol
|
|
configMap:
|
|
name: restic-backup-script
|
|
|
|
initContainers:
|
|
- name: postgres-dump-init
|
|
image: bitnami/postgresql:16.3.0-debian-12-r14@sha256:cc55da2fa3660b5c97539cd050ac676c452e02693e1ed2e742f9e7bf07784755
|
|
command: ["/bin/sh", "-c"]
|
|
args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /backup/postgres_backup.dump"]
|
|
env:
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: gitea-postgresql
|
|
key: password
|
|
volumeMounts:
|
|
- name: restic-backup-vol
|
|
mountPath: /backup
|
|
|
|
containers:
|
|
- name: restic-container
|
|
image: git.namesny.com/cluster/restic:latest@sha256:8efb9776d9b3250012d17bbfff865420e5ffa0688010d006448c4ff358b0ee32
|
|
imagePullPolicy: Always
|
|
command: ["/bin/sh", "/app/backup.sh"]
|
|
envFrom:
|
|
- secretRef:
|
|
name: restic-secret
|
|
volumeMounts:
|
|
- name: restic-backup-vol
|
|
mountPath: /backup
|
|
- name: gitea-data
|
|
mountPath: /gitea
|
|
- name: backup-script-vol
|
|
mountPath: /app
|
|
|
|
restartPolicy: OnFailure
|