pg backup as well

This commit is contained in:
2023-11-28 22:28:34 +01:00
parent 7fcc5738bd
commit c762a58080
7 changed files with 99 additions and 32 deletions

View File

@@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: postgres-backup
spec:
# Backup the database every day at 1AM
schedule: "0 1 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: postgres-backup
image: postgres:15
command: ["/bin/sh"]
args:
- "-c"
- >-
echo "$postgress_password" > /root/.pgpass
&&
chmod 600 /root/.pgpass
&&
pg_dumpall -U postgres -h postgrespostgres-postgresql.postgres > /backup/backup-$(date +"%m-%d-%Y-%H-%M").sql
env:
- name: PGpostgress_passwordPASS
valueFrom:
secretKeyRef:
name: postgres-password
key: password
volumeMounts:
- mountPath: /backup
name: postgres-backup-claim
restartPolicy: Never
volumes:
- name: postgres-backup-claim
persistentVolumeClaim:
claimName: postgres-backup-claim