41 lines
1.1 KiB
YAML
41 lines
1.1 KiB
YAML
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: postgres-backup
|
|
spec:
|
|
schedule: "0 0 * * *"
|
|
jobTemplate:
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: postgres-backup
|
|
image: postgres:15-alpine
|
|
command: ["sh", "/backup-script.sh"]
|
|
env:
|
|
- name: PG_HOST
|
|
value: postgres-postgresql
|
|
- name: PG_USER
|
|
value: backup
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: backupscrets
|
|
key: pgbackupsecret
|
|
volumeMounts:
|
|
- name: backup-volume
|
|
mountPath: /backup
|
|
subPath: postgres
|
|
- name: backup-script
|
|
mountPath: /backup-script.sh
|
|
subPath: backup-script.sh
|
|
readOnly: true
|
|
restartPolicy: OnFailure
|
|
volumes:
|
|
- name: backup-volume
|
|
persistentVolumeClaim:
|
|
claimName: nfs-postgresbackup-claim
|
|
- name: backup-script
|
|
configMap:
|
|
name: postgres-backup-script
|