Skip to content

Commit

Permalink
Merge pull request #109 from drpebcak/more-config
Browse files Browse the repository at this point in the history
More backup enhancements
  • Loading branch information
wallyqs authored Aug 31, 2020
2 parents 349f7ff + 1c32236 commit be0cc2c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
9 changes: 9 additions & 0 deletions helm/charts/stan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,16 @@ store:
Example that will back up the file store when operating in clustered mode:

```yaml
stan:
image: nats-streaming:0.18.0-alpine
store:
limits:
max_msgs: 5
file:
options:
slice_max_msgs: 0
backup:
enabled: true
s3Path: s3://example-bucket/stan-backups
Expand Down
5 changes: 4 additions & 1 deletion helm/charts/stan/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ data:
{{- else }}
store: "file"
dir: {{ .Values.store.file.path }}
{{- end }}
{{- with .Values.store.file.options }}
file_options: {{ toPrettyJson . | indent 6 }}
{{- end }}
{{- end }}
{{- if .Values.store.cluster.enabled }}
cluster {
Expand Down
12 changes: 9 additions & 3 deletions helm/charts/stan/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
volumes:
- configMap:
name: {{ template "stan.name". }}-config
defaultMode: 0755
name: config-volume
{{- if and .Values.stan.tls.enabled .Values.stan.tls.secretName }}
- name: stan-client-tls-volume
Expand Down Expand Up @@ -153,11 +154,16 @@ spec:
while true; do
aws s3 cp \
{{ .Values.store.file.path }} \
{{ required "A valid s3 path is required!" .Values.store.backup.s3Path }}/{{ template "stan.name" . }}/$POD_NAME/ --recursive
{{ required "A valid s3 path is required!" .Values.store.backup.s3Path }}/{{ template "stan.name" . }}/${POD_NAME}/ --recursive
find {{ .Values.store.file.path }} -name '*.bak' -delete
RESULT=$?
if [ $RESULT -eq 0 ]; then
find {{ .Values.store.file.path }} -name '*.bak' -delete
else
echo "Error backing up! Do not remove .bak files."
fi
sleep $(SLEEP_TIME)
sleep "${SLEEP_TIME}"
done
env:
- name: SLEEP_TIME
Expand Down
10 changes: 10 additions & 0 deletions helm/charts/stan/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ store:
#
file:
path: /data/stan/store
# Configures streaming/file_options as is.
#
# NOTE: Section in snake case since they will become
# the same objects.
#
# Look at the NATS Streaming configuration for this:
#
# https://docs.nats.io/nats-streaming-server/configuring/cfgfile#file-options-configuration
#
options: {}

# In case of using file or sql storage, sets up a 3 node cluster.
cluster:
Expand Down

0 comments on commit be0cc2c

Please sign in to comment.