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
|
2024-07-03 09:27:06 +00:00
|
|
|
image: bitnami/postgresql:16.3.0-debian-12-r17@sha256:5f5da81926e99bde90bd188bb43bf8de4bbcc1da45087e375631693e82d8b1c7
|
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
|