Skip to content

Commit

Permalink
Split PostgreSQL / MongoDB backup chart (#3)
Browse files Browse the repository at this point in the history
* Split PostgreSQL / MongoDB backup chart

* Bump chart versions
  • Loading branch information
Pyrofab authored May 24, 2024
1 parent a47e7db commit 31ac3db
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 79 deletions.
10 changes: 5 additions & 5 deletions charts/cozy/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies:
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 13.16.2
- name: s3-backups
repository: file://../s3-backups
version: 0.2.0
digest: sha256:ed55f38f351d0d9cd5a4485e23bd71277408eb0f2362f1cc4ed6d8e49c90384f
generated: "2024-05-12T02:48:54.590979+02:00"
- name: mongodb-s3-backup
repository: file://../mongodb-s3-backup
version: 1.0.0
digest: sha256:807610a2e401438e1bf29efda6c39dbced7dd9cc557681e2f23eb773cf091bd6
generated: "2024-05-12T19:44:03.053907+02:00"
8 changes: 4 additions & 4 deletions charts/cozy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: quilt-cozy
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.1.4
version: 1.1.5
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: helm chart to deploy the Quilt Cozy Discord bot
Expand All @@ -20,6 +20,6 @@ dependencies:
- name: mongodb
version: 13.16.2
repository: https://charts.bitnami.com/bitnami
- name: s3-backups
version: 0.2.0
repository: 'file://../s3-backups'
- name: mongodb-s3-backup
version: 1.0.0
repository: 'file://../mongodb-s3-backup'
2 changes: 1 addition & 1 deletion charts/cozy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ mongodb:
databases:
- cozy

s3-backups:
mongodb-s3-backup:
database:
password: cozy
10 changes: 5 additions & 5 deletions charts/forum/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 17.17.1
- name: s3-backups
repository: file://../s3-backups
version: 0.2.0
digest: sha256:6ad85e467301603ce3782e8e81f68932fc399302bc4aa5dad9dea8836cf92ee4
generated: "2024-05-12T02:49:15.499456+02:00"
- name: postgresql-s3-backup
repository: file://../postgresql-s3-backup
version: 1.0.0
digest: sha256:f4f3b3f6fb9ba88f2ee54fda6f7da94a2667bd88ec37210cda738a2a06c38b41
generated: "2024-05-12T19:44:14.415514+02:00"
8 changes: 4 additions & 4 deletions charts/forum/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: quilt-forum
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.1
version: 0.2.2
# This is the version number of the Discourse image being deployed (purely informational).
appVersion: '3.2.1'
description: helm chart to deploy the Quilt Discourse Forum
Expand All @@ -26,6 +26,6 @@ dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 17.X.X
- name: s3-backups
version: 0.2.0
repository: 'file://../s3-backups'
- name: postgresql-s3-backup
version: 1.0.0
repository: 'file://../postgresql-s3-backup'
3 changes: 1 addition & 2 deletions charts/forum/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ postgresql:
database: "forum_quiltmc_org"
password: "default"

s3-backups:
postgresql-s3-backup:
database:
type: 'postgresql'
dbName: "forum_quiltmc_org"
username: "forum_quiltmc_org"
password: "default"
Expand Down
10 changes: 5 additions & 5 deletions charts/modmail/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies:
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 13.16.2
- name: s3-backups
repository: file://../s3-backups
version: 0.2.0
digest: sha256:ed55f38f351d0d9cd5a4485e23bd71277408eb0f2362f1cc4ed6d8e49c90384f
generated: "2024-05-12T02:51:30.626063+02:00"
- name: mongodb-s3-backup
repository: file://../mongodb-s3-backup
version: 1.0.0
digest: sha256:807610a2e401438e1bf29efda6c39dbced7dd9cc557681e2f23eb773cf091bd6
generated: "2024-05-12T19:44:24.507366+02:00"
8 changes: 4 additions & 4 deletions charts/modmail/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: quilt-modmail
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.1.4
version: 1.1.5
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: helm chart to deploy Quilt's Modmail Discord bot
Expand All @@ -20,6 +20,6 @@ dependencies:
- name: mongodb
version: 13.16.2
repository: https://charts.bitnami.com/bitnami
- name: s3-backups
version: 0.2.0
repository: 'file://../s3-backups'
- name: mongodb-s3-backup
version: 1.0.0
repository: 'file://../mongodb-s3-backup'
2 changes: 1 addition & 1 deletion charts/modmail/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ mongodb:
databases:
- modmail

s3-backups:
mongodb-s3-backup:
database:
password: modmail
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Spec: https://helm.sh/docs/topics/charts/#the-chartyaml-file
apiVersion: v2
name: s3-backups
name: mongodb-s3-backup
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 1.0.0
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: helm chart handling Quilt's backups to an S3
description: helm chart handling Quilt's MongoDB backups to an S3
home: https://github.com/QuiltMC/quilt-helm-charts
# A chart can be either an 'application' or a 'library' chart.
type: application
Expand All @@ -16,7 +16,3 @@ maintainers:
email: [email protected]
- name: tibs
email: [email protected]
dependencies:
- name: mongodb
version: 13.16.2
repository: https://charts.bitnami.com/bitnami
28 changes: 28 additions & 0 deletions charts/mongodb-s3-backup/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{ if .Values.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .Release.Name }}-mongodb-backup
spec:
schedule: "0 0 * * *"
jobTemplate:
spec:
ttlSecondsAfterFinished: 3600
template:
spec:
containers:
- name: backup
image: {{ .Values.image }}
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- >
EXT=gz &&
mongodump -h="{{ tpl .Values.database.host . }}" -u="{{ .Values.database.username | default "root" }}" -p="{{ .Values.database.password }}" --gzip --archive="backup.$EXT" &&
aws --endpoint {{ .Values.endpoint }} s3 cp backup.gz s3://quilt-backups/{{ .Release.Name }}/`date -I`.$EXT
envFrom:
- secretRef:
# should contain AWS credentials environment variables
name: {{ .Values.awsSecretName }}
restartPolicy: OnFailure
{{ end }}
8 changes: 8 additions & 0 deletions charts/mongodb-s3-backup/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enabled: true
database:
host: '{{ .Release.Name }}-mongodb'
username: ''
password: ''
awsSecretName: 'quilt-backups'
endpoint: 'https://s3.eu-central-003.backblazeb2.com'
image: 'ghcr.io/quiltmc/mongodb-s3-backup:4b26b78'
18 changes: 18 additions & 0 deletions charts/postgresql-s3-backup/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Spec: https://helm.sh/docs/topics/charts/#the-chartyaml-file
apiVersion: v2
name: postgresql-s3-backup
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: Helm chart handling Quilt's PostgreSQL backups to an S3
home: https://github.com/QuiltMC/quilt-helm-charts
# A chart can be either an 'application' or a 'library' chart.
type: application
maintainers:
- name: Pyrofab
email: [email protected]
- name: tibs
email: [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .Release.Name }}-{{ .Values.database.type }}-backup
name: {{ .Release.Name }}-postgresql-backup
spec:
schedule: "0 0 * * *"
jobTemplate:
Expand All @@ -12,24 +12,14 @@ spec:
spec:
containers:
- name: backup
{{- if eq .Values.database.type "mongodb" }}
image: ghcr.io/quiltmc/mongodb-s3-backup:latest
{{- else if eq .Values.database.type "postgresql" }}
image: ghcr.io/quiltmc/postgresql-s3-backup:latest
{{- end }}
image: {{ .Values.image }}
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- >
{{- if eq .Values.database.type "mongodb" }}
EXT=gz &&
mongodump -h="{{ tpl .Values.database.host . }}" -u="{{ .Values.database.username | default "root" }}" -p="{{ .Values.database.password }}" --gzip --archive="backup.$EXT" &&
{{- else if eq .Values.database.type "postgresql" }}
EXT=pgdump &&
pg_dump {{ .Values.database.dbName }} --clean --if-exists --quote-all-identifiers --no-password --file=backup.$EXT &&
{{- end }}
aws --endpoint {{ .Values.endpoint }} s3 cp backup.gz s3://quilt-backups/{{ .Release.Name }}/`date -I`.$EXT
{{- if eq .Values.database.type "postgresql" }}
env:
- name: PGUSER
value: {{ .Values.database.username }}
Expand All @@ -39,7 +29,6 @@ spec:
value: {{ tpl .Values.database.host . }}
- name: PGPORT
value: '5432'
{{- end }}
envFrom:
- secretRef:
# should contain AWS credentials environment variables
Expand Down
9 changes: 9 additions & 0 deletions charts/postgresql-s3-backup/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enabled: true
database:
host: '{{ .Release.Name }}-postgresql'
username: ''
password: ''
dbName:
awsSecretName: 'quilt-backups'
endpoint: 'https://s3.eu-central-003.backblazeb2.com'
image: 'ghcr.io/quiltmc/postgresql-s3-backup:4b26b78'
6 changes: 0 additions & 6 deletions charts/s3-backups/Chart.lock

This file was deleted.

11 changes: 0 additions & 11 deletions charts/s3-backups/values.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions charts/stats/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 12.8.0
- name: s3-backups
repository: file://../s3-backups
version: 0.2.0
digest: sha256:48d01dbddab226ed5d1e4166fab44ee771ffbb781cdb5c447d35d67b1901526e
generated: "2024-05-12T02:51:42.396378+02:00"
- name: postgresql-s3-backup
repository: file://../postgresql-s3-backup
version: 1.0.0
digest: sha256:cb94b35f08891be94dabd90d1d4a35f2c741375db721642037334067b1cf74ba
generated: "2024-05-12T19:44:32.821466+02:00"
8 changes: 4 additions & 4 deletions charts/stats/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: quilt-stats
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.1.4
version: 1.1.5
# This is the version number of the application being deployed (purely informational).
appVersion: '1'
description: helm chart to deploy Quilt's Stats Discord bot
Expand All @@ -20,6 +20,6 @@ dependencies:
- name: postgresql
version: 12.8.0
repository: https://charts.bitnami.com/bitnami
- name: s3-backups
version: 0.2.0
repository: 'file://../s3-backups'
- name: postgresql-s3-backup
version: 1.0.0
repository: 'file://../postgresql-s3-backup'
3 changes: 1 addition & 2 deletions charts/stats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ postgresql:
postgresPassword: stats
database: metabase

s3-backups:
postgresql-s3-backup:
database:
type: "postgresql"
host: "{{ .Release.Name }}-postgresql:5432"
password: stats
dbName: metabase

0 comments on commit 31ac3db

Please sign in to comment.