Skip to content

Commit

Permalink
Sidecar Backup (#8)
Browse files Browse the repository at this point in the history
* backup

* backup

* backup

* backup

* backup

* cleanup

* Fix file perm
  • Loading branch information
james-otten authored Nov 9, 2024
1 parent e25b38a commit 2fefd0c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ data:
backup_name="wiki_backup_files_$(date +%s).tar.gz"
tar -chzvf $backup_name /app/www/public/uploads/ /app/www/storage/uploads/ /app/www/public/img/
echo "push to s3"
apk add aws-cli
aws s3 cp ./$backup_name "$BACKUP_S3_URL"
echo "uploaded"
rm $backup_name
echo "done"
backup.files.hook.sh: |
echo "setting hook"
backup.entrypoint.sh: |
echo "Startup"
apk add aws-cli
echo "sh /backup.files.sh" >> /etc/periodic/daily/backup
crond
echo "done"
chmod +x /etc/periodic/daily/backup
echo "Starting crond"
crond -f
echo "Error: Cron exited"
restore.db.sh: |
echo "Checking if restore is needed"
echo "Restore file is: $RESTORE_S3_URL"
Expand Down
55 changes: 43 additions & 12 deletions bookstack-helm/templates/bookstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ .Values.bookstack.service.port }}
protocol: TCP
env:
- name: TZ
Expand Down Expand Up @@ -140,10 +140,6 @@ spec:
mountPath: /backup.files.sh
subPath: backup.files.sh
readOnly: true
- name: backup-hook
mountPath: /backup.files.hook.sh
subPath: backup.files.hook.sh
readOnly: true
{{- if .Values.bookstack.enableLivenessProbe }}
livenessProbe:
httpGet:
Expand All @@ -162,10 +158,45 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.bookstack.resources | nindent 12 }}
lifecycle:
postStart:
exec:
command: ["/bin/sh", "/backup.files.hook.sh"]
initContainers:
- name: backup-cron
image: alpine:latest
restartPolicy: Always
command: ['sh', '/backup.entrypoint.sh']
env:
- name: APP_URL
valueFrom:
configMapKeyRef:
name: wikiconfig
key: APP_URL
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: wiki-secrets
key: access-key-id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: wiki-secrets
key: secret-access-key
- name: BACKUP_S3_URL
valueFrom:
secretKeyRef:
name: wiki-secrets
key: backup-s3-url
volumeMounts:
- name: config-vol
mountPath: /config
- name: image-uploads-vol
mountPath: /app/www/public/img
- name: backup-script
mountPath: /backup.files.sh
subPath: backup.files.sh
readOnly: true
- name: backup-entrypoint
mountPath: /backup.entrypoint.sh
subPath: backup.entrypoint.sh
readOnly: true
volumes:
- name: config-vol
persistentVolumeClaim:
Expand All @@ -179,12 +210,12 @@ spec:
items:
- key: backup.files.sh
path: backup.files.sh
- name: backup-hook
- name: backup-entrypoint
configMap:
name: backup-script
items:
- key: backup.files.hook.sh
path: backup.files.hook.sh
- key: backup.entrypoint.sh
path: backup.entrypoint.sh
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 0 additions & 2 deletions bookstack-helm/templates/bookstack_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ metadata:
labels:
{{- include "bookstack-helm.labels" . | nindent 4 }}
spec:
type: NodePort
ports:
- port: {{ .Values.bookstack.port }}
targetPort: {{ .Values.bookstack.port }}
protocol: TCP
name: http
nodePort: 30875
selector:
app: bookstack
5 changes: 2 additions & 3 deletions bookstack-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ bookstack:
enableLivenessProbe: true
livenessProbeInitialDelaySeconds: 20
livenessProbePeriodSeconds: 15
service:
port: 8080

image:
repository: lscr.io/linuxserver/bookstack
Expand Down Expand Up @@ -84,9 +86,6 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

service:
port: 8080

# autoscaling:
# enabled: false
# minReplicas: 1
Expand Down

0 comments on commit 2fefd0c

Please sign in to comment.