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

59 lines
1.8 KiB
YAML
Raw Normal View History

2024-01-30 19:44:56 +00:00
apiVersion: batch/v1
2024-01-22 20:55:48 +00:00
kind: CronJob
metadata:
name: restic-backup-cronjob
namespace: gitea
spec:
2024-05-28 21:33:44 +00:00
schedule: "0 3 * * *" # Cron expression for running daily at 2 AM
2024-01-22 20:55:48 +00:00
jobTemplate:
spec:
template:
spec:
2024-01-30 16:12:59 +00:00
2024-01-30 19:44:56 +00:00
serviceAccountName: restic-sa
2024-02-10 22:48:03 +00:00
hostname: restic-cronjob
2024-01-30 16:12:59 +00:00
2024-01-22 20:55:48 +00:00
volumes:
- name: gitea-data
2024-01-30 16:12:59 +00:00
persistentVolumeClaim:
claimName: gitea-shared-storage
2024-02-01 16:25:19 +00:00
- name: restic-backup-vol
2024-01-22 20:55:48 +00:00
persistentVolumeClaim:
2024-02-01 16:25:19 +00:00
claimName: restic-backup-vol
2024-01-30 19:44:56 +00:00
- name: backup-script-vol
2024-01-30 16:12:59 +00:00
configMap:
name: restic-backup-script
2024-01-22 20:55:48 +00:00
initContainers:
- name: postgres-dump-init
image: bitnami/postgresql:15.7.0-debian-12-r7@sha256:fd120faed7235327592d60c901909d9d8d9e2ed170ec57f7554d5d4342bbb659
2024-01-22 20:55:48 +00:00
command: ["/bin/sh", "-c"]
2024-02-01 16:25:19 +00:00
args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /backup/postgres_backup.dump"]
2024-01-30 19:44:56 +00:00
env:
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: gitea-postgresql
2024-03-24 17:05:07 +00:00
key: password
2024-01-22 20:55:48 +00:00
volumeMounts:
2024-02-01 16:25:19 +00:00
- name: restic-backup-vol
mountPath: /backup
2024-01-22 20:55:48 +00:00
containers:
- name: restic-container
2024-06-03 13:06:19 +00:00
image: git.namesny.com/cluster/restic:latest@sha256:8efb9776d9b3250012d17bbfff865420e5ffa0688010d006448c4ff358b0ee32
2024-01-30 16:12:59 +00:00
imagePullPolicy: Always
2024-02-01 17:44:03 +00:00
command: ["/bin/sh", "/app/backup.sh"]
2024-01-30 19:44:56 +00:00
envFrom:
- secretRef:
name: restic-secret
2024-01-22 20:55:48 +00:00
volumeMounts:
2024-02-01 16:25:19 +00:00
- name: restic-backup-vol
mountPath: /backup
2024-01-30 16:12:59 +00:00
- name: gitea-data
mountPath: /gitea
2024-01-30 19:44:56 +00:00
- name: backup-script-vol
2024-01-30 16:12:59 +00:00
mountPath: /app
2024-01-22 20:55:48 +00:00
restartPolicy: OnFailure