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

62 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:
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-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-01-22 20:55:48 +00:00
- name: postgres-data
persistentVolumeClaim:
claimName: data-gitea-postgresql-0
2024-01-30 16:12:59 +00:00
- name: postgres-backup-vol
emptyDir: {}
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-01-30 19:44:56 +00:00
args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /pg_backup/postgres_backup.dump"]
env:
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: gitea-postgresql
key: postgres-password
2024-01-22 20:55:48 +00:00
volumeMounts:
2024-01-30 19:44:56 +00:00
- name: postgres-backup-vol
2024-01-30 16:12:59 +00:00
mountPath: /pg_backup
2024-01-22 20:55:48 +00:00
- name: postgres-data
mountPath: /bitnami/postgresql/data
containers:
- name: restic-container
2024-01-30 16:12:59 +00:00
image: git.namesny.com/cluster/restic:latest
imagePullPolicy: Always
2024-01-30 19:44:56 +00:00
command: ["/bin/sh", "/app/restic-backup.sh"]
envFrom:
- secretRef:
name: restic-secret
2024-01-22 20:55:48 +00:00
volumeMounts:
2024-01-30 19:44:56 +00:00
- name: postgres-backup-vol
2024-01-30 16:12:59 +00:00
mountPath: /pg_backup
- 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