k3s-configs/apps/gitea/restic/cronjob.yaml

59 lines
1.7 KiB
YAML

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: 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.3.0-debian-11-r24
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: postgres-password
volumeMounts:
- name: restic-backup-vol
mountPath: /backup
containers:
- name: restic-container
hostname: restic-cronjob
image: git.namesny.com/cluster/restic:latest
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