26 lines
991 B
YAML
26 lines
991 B
YAML
|
apiVersion: batch/v1
|
||
|
kind: CronJob
|
||
|
metadata:
|
||
|
name: backup-job
|
||
|
namespace: synapse
|
||
|
spec:
|
||
|
schedule: "0 4 * * *" # Every day at 4AM
|
||
|
concurrencyPolicy: Forbid
|
||
|
jobTemplate:
|
||
|
spec:
|
||
|
template:
|
||
|
spec:
|
||
|
containers:
|
||
|
- name: postgres-backup
|
||
|
image: postgres:14-alpine3.15
|
||
|
command: ["sh", "-c", "PGPASSWORD=aberation /usr/local/bin/pg_dumpall -U synapse -h synapse-svc.synapse.svc.cluster.local > /backup/synapse/backup-$(date +'%H_%M-%d_%m_%Y').sql"]
|
||
|
volumeMounts:
|
||
|
- name: synapse-backup
|
||
|
mountPath: /backup/synapse
|
||
|
subPath: synapse
|
||
|
volumes:
|
||
|
- name: synapse-backup
|
||
|
persistentVolumeClaim:
|
||
|
claimName: synapse-backup-pvc
|
||
|
restartPolicy: OnFailure
|