Skip to content

Commit

Permalink
Merge pull request #708 from MetaCell/feature/707
Browse files Browse the repository at this point in the history
Feature/707
  • Loading branch information
filippomc authored Sep 26, 2023
2 parents 36791b2 + 6fb75cd commit 1d9aef6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
10 changes: 0 additions & 10 deletions deployment-configuration/helm/templates/auto-database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ spec:
volumeMounts:
- name: {{ .app.harness.database.name | quote }}
mountPath: /data/db
{{- if .root.Values.backup.active }}
- name: "db-backups"
mountPath: {{ (printf "%s/%s/%s" .root.Values.backup.dir .app.harness.database.type .app.harness.database.name) | quote }}
readOnly: true
{{- end }}
{{- if eq .app.harness.database.type "postgres" }}
- mountPath: /dev/shm
name: dshm
Expand All @@ -92,11 +87,6 @@ spec:
medium: Memory
name: dshm
{{- end }}
{{- if .root.Values.backup.active }}
- name: "db-backups"
persistentVolumeClaim:
claimName: "db-backups"
{{- end }}
---
{{- if .root.Values.backup.active }}
{{- include (print "deploy_utils.database." .app.harness.database.type ".backup") . }}
Expand Down
39 changes: 37 additions & 2 deletions docs/applications/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,49 @@ Per default, database backups are disabled. However, you can overwrite backups b

```yaml
backup:
active: true
active: true
```

See all the default values [here](../../deployment-configuration/helm/values.yaml).
You can find additional configuration fields for backups to overwrite in the generated `deployment/helm/values.yaml` once you deploy your applications.

Backups are defined for `mongo` and `postgres` database in form of a [K8s CronJob](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) that creates a dump of the database and stores it in a different persistent volume on the same cluster.

This is done periodically according to a configurable schedule, per default once a day.
This is done periodically according to a configurable schedule, per default every 5 minutes.

A smart retention strategy is used for backups, by default:
- all current days backups
- one per day, last 7 days
- one per week, last 4 weeks
- one per month, last 6 months

Implementation of backups and retention is based on https://github.com/prodrigestivill/docker-postgres-backup-local.

#### How to monitor and restore backups

Backups are stored in a Kubernetes volume named `db-backups`.

Can mount the volume to your database pod by adding the following to your db deployment:

```yaml
...
spec:
template:
spec:
containers:
- ...
volumeMounts:
- name: "db-backups"
mountPath: /backups
readOnly: true
...
volumes:
...
- name: "db-backups"
persistentVolumeClaim:
claimName: "db-backups"
```



### MongoDB
Expand Down

0 comments on commit 1d9aef6

Please sign in to comment.