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:
|
|
|
|
schedule: "0 2 * * *" # Cron expression for running daily at 2 AM
|
|
|
|
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.3.0-debian-11-r24
|
|
|
|
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
|
|
|
|
key: postgres-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-01-30 16:12:59 +00:00
|
|
|
image: git.namesny.com/cluster/restic:latest
|
|
|
|
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
|