-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from SUSE/postgres-backup
Adds postgres backup cronjob
- Loading branch information
Showing
6 changed files
with
108 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: postgres-backup | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
{{- if .Values.openplatform.enabled }} | ||
schedule: {{ required "A value for schedule is required" .Values.openplatform.backupSchedule | quote }} | ||
{{- else }} | ||
schedule: {{ required "A value for schedule is required" .Values.postgres.backup.schedule | quote }} | ||
{{- end }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: {{ .Values.postgres.backup.containerName }} | ||
image: {{ .Values.postgres.backup.containerImage }} | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
apt update | ||
apt install -y awscli | ||
pg_dump -h postgres -U $POSTGRES_USER $POSTGRES_DB > /backup/backup.sql | ||
aws s3 cp /backup/backup.sql s3://$AWS_BUCKET/backups/backup-$(date +%Y%m%d).sql | ||
env: | ||
- name: POSTGRES_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: postgres-config | ||
key: POSTGRES_USER | ||
- name: PGPASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: postgres-config | ||
key: POSTGRES_PASSWORD | ||
- name: POSTGRES_DB | ||
valueFrom: | ||
secretKeyRef: | ||
name: postgres-config | ||
key: POSTGRES_DB | ||
- name: AWS_ACCESS_KEY_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: aws-credentials | ||
key: aws_access_key_id | ||
- name: AWS_SECRET_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: aws-credentials | ||
key: aws_secret_access_key | ||
- name: AWS_BUCKET | ||
value: {{ .Values.postgres.backup.awsBucket }} | ||
volumeMounts: | ||
- name: backup-storage | ||
mountPath: /backup | ||
volumes: | ||
- name: backup-storage | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters