Implement restic-backup for Gitea #46
|
@ -0,0 +1,53 @@
|
||||||
|
apiVersion: batch/v1beta1
|
||||||
|
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:
|
||||||
|
volumes:
|
||||||
|
- name: gitea-data
|
||||||
|
emptyDir: {}
|
||||||
|
- name: backup-vol
|
||||||
|
emptyDir: {}
|
||||||
|
- name: postgres-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: data-gitea-postgresql-0
|
||||||
|
|
||||||
|
initContainers:
|
||||||
|
- name: postgres-dump-init
|
||||||
|
image: bitnami/postgresql:15.3.0-debian-11-r24
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args: ["pg_dump -U gitea gitea -Fc > /backup-vol/postgres_backup.dump"]
|
||||||
|
env:
|
||||||
|
- name: PGPASSWORD
|
||||||
|
value: "<password>"
|
||||||
|
volumeMounts:
|
||||||
|
- name: backup-vol
|
||||||
|
mountPath: /backup-vol
|
||||||
|
- name: postgres-data
|
||||||
|
mountPath: /bitnami/postgresql/data
|
||||||
|
|
||||||
|
- name: gitea-dump-init
|
||||||
|
image: gitea-image:tag
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args: ["cp /path/to/backup.zip /backup-vol/backup.zip"]
|
||||||
|
volumeMounts:
|
||||||
|
- name: gitea-data
|
||||||
|
mountPath: /path/to/backup
|
||||||
|
- name: backup-vol
|
||||||
|
mountPath: /backup-vol
|
||||||
|
|
||||||
|
containers:
|
||||||
|
- name: restic-container
|
||||||
|
image: git.namesny.com/cluster/restic:0.16.2-r0
|
||||||
|
command: ["/bin/bash", "/path/to/backup.sh"]
|
||||||
|
volumeMounts:
|
||||||
|
- name: backup-vol
|
||||||
|
mountPath: /backup-vol
|
||||||
|
|
||||||
|
restartPolicy: OnFailure
|
Loading…
Reference in New Issue