k3s-configs/apps/gitea/restic/cronjob.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:15.7.0-debian-12-r9@sha256:69e36cb64324418ce1933cea03a94b8774356d91ea53644db19469ba1383d614
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