pg backup as well
This commit is contained in:
37
infrastructure/backup/postgres/cronjob.yaml
Normal file
37
infrastructure/backup/postgres/cronjob.yaml
Normal 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
|
Reference in New Issue
Block a user