-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e12d934
commit b8489c7
Showing
8 changed files
with
139 additions
and
0 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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.iml | ||
local/ | ||
/.cr-release-packages | ||
/values.yaml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v2 | ||
name: pg-db-backup-do-space | ||
description: This chart is used to set up a job which saves the content of a Digital Ocean database as SQL into a Digital Ocean space. | ||
|
||
type: application | ||
|
||
version: 0.1.0 | ||
appVersion: "0.1.0" |
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,19 @@ | ||
[`pg-db-backup-do-space`](values.yaml) | ||
====================================== | ||
|
||
This chart is used to set up a job which saves the content of a Digital Ocean database | ||
as SQL into a Digital Ocean space. | ||
|
||
# Usage | ||
|
||
```bash | ||
helm install my-db-owner postgres-helpers/pg-db-backup-do-space --values values.yaml | ||
``` | ||
|
||
> See [`values.yaml`](values.yaml) for the list of options. | ||
# Change log | ||
|
||
## 0.1.0 | ||
|
||
* Initial version |
47 changes: 47 additions & 0 deletions
47
charts/pg-db-backup-do-space/templates/db-extraction-job.yaml
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,47 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: "{{ .Release.Name }}-pg-db-backup-do-space" | ||
spec: | ||
schedule: {{ .Values.backup.schedule | quote }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: extraction | ||
image: "postgres:{{ .Values.database.version }}" | ||
imagePullPolicy: IfNotPresent | ||
command: [ "sh", "-c" ] | ||
args: | ||
- | | ||
pg_dump \ | ||
--username {{ .Values.auth.username }} \ | ||
--no-password \ | ||
--dbname {{ .Values.database.name }} \ | ||
--host {{ .Values.connection.host }} \ | ||
--port {{ .Values.connection.port }} \ | ||
--file dump.sql | ||
apt-get update | ||
apt-get install -y s3cmd | ||
s3cmd \ | ||
--access_key=${DO_SPACE_ACCESS_KEY} \ | ||
--secret_key=${DO_SPACE_SECRET_KEY} \ | ||
--host={{ .Values.digitalocean.space.region }}.digitaloceanspaces.com \ | ||
--host-bucket='%(bucket)s.{{ .Values.digitalocean.space.region }}.digitaloceanspaces.com' \ | ||
put \ | ||
dump.sql \ | ||
s3://{{ .Values.digitalocean.space.bucket }}/{{ .Values.digitalocean.space.path.root }}/{{ .Values.database.name }}/dump-$(date +%Y%m%d%H%M%S).sql | ||
env: | ||
- name: PGSSLMODE | ||
value: "require" | ||
- name: PGPASSWORD | ||
value: {{ .Values.auth.password | quote }} | ||
- name: DO_SPACE_ACCESS_KEY | ||
value: {{ .Values.digitalocean.space.accessKey | quote }} | ||
- name: DO_SPACE_SECRET_KEY | ||
value: {{ .Values.digitalocean.space.secretKey | quote }} |
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,17 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: "{{ .Release.Name }}-pg-db-backup" | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: {{ .Values.persistence.size | quote }} | ||
{{- if .Values.persistence.storageClass }} | ||
{{- if (eq "-" .Values.persistence.storageClass) }} | ||
storageClassName: "" | ||
{{- else }} | ||
storageClassName: "{{ .Values.persistence.storageClass }}" | ||
{{- end }} | ||
{{- end }} |
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,45 @@ | ||
--- | ||
# Temporary space | ||
persistence: | ||
# Size of the working directory where to put the SQL file | ||
size: 2Gi | ||
# Storage class to be used (empty for default) | ||
storageClass: "" | ||
# Extraction parameters | ||
backup: | ||
# Schedule | ||
schedule: "0 0 * * *" | ||
# Connection to the PG cluster | ||
connection: | ||
# Host name or IP | ||
host: "" | ||
# Port to reach the PG cluster | ||
port: 0 | ||
# Credentials to connect to the PG cluster as DB admin | ||
auth: | ||
# User name | ||
username: "" | ||
# Password | ||
password: "" | ||
# Database to backup | ||
database: | ||
# Version of PG to use | ||
version: 15 | ||
# Name of the database to backup | ||
name: "" | ||
# Digital Ocean setup | ||
digitalocean: | ||
# Space to target | ||
space: | ||
# Access key | ||
accessKey: "" | ||
# Secret key | ||
secretKey: "" | ||
# Region | ||
region: "fra1" | ||
# Bucket | ||
bucket: "ontrack-run-do-env-production-eu-cluster-database-backup" | ||
# Path definition | ||
path: | ||
# Root | ||
root: sql |