Unverified Commit 93d0e9ea authored by Shaun Elliott's avatar Shaun Elliott Committed by GitHub

(ISSUE 196) - added neo4j backup cron pod (#281)

* * setting up a pvc to allow for neo4j backups

* * allowing pvc to be turned off
* allowing pvc size to be configurable

* ISSUE 196
* added neo4j plugins
* added chart versions
* removed image pull policy never from metadata service

* * PR comment fix; using the correct maven repo urls

* (ISSUE 196) - added neo4j s3 backup cron pod

* * added missing restartPolicy

* (ISSUE 196)
* updated for PR comments
* using export schema, export graphml functions
parent 707a0dd4
name: neo4j name: neo4j
home: https://www.neo4j.com home: https://www.neo4j.com
appVersion: 3.3.0 appVersion: 3.3.0
version: 0.1.0 version: 0.2.0
\ No newline at end of file \ No newline at end of file
{{ if and (and .Values.neo4j.backup.enabled (eq .Values.provider "aws")) (or (kindIs "invalid" .Values.neo4jpvc) .Values.neo4jpvc) }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: neo4j-s3-backup
spec:
schedule: {{ .Values.neo4j.backup.schedule }}
jobTemplate:
spec:
template:
spec:
containers:
- name: backup-neo4j
image: mesosphere/aws-cli:latest
command:
- "/bin/sh"
- "-c"
- |
apk -v --update add --no-cache --quiet curl
NOW="$(date "+%Y-%m-%d-%H:%M:%S")"
BACKUP_SCHEMA_NAME="graph.db-backup-$NOW.schema"
BACKUP_DATA_NAME="graph.db-backup-$NOW.data"
BACKUP_NAME="graph.db-backup-$NOW"
curl --user neo4j:test -H accept:application/json -H content-type:application/json \
-d '{"statements":[{"statement":"CALL apoc.export.cypher.schema(\"\/var\/lib\/neo4j\/data\/'$BACKUP_SCHEMA_NAME'\", {})"}]}' \
http://neo4j:7474/db/data/transaction/commit
curl --user neo4j:test -H accept:application/json -H content-type:application/json \
-d '{"statements":[{"statement":"CALL apoc.export.graphml.all(\"\/var\/lib\/neo4j\/data\/'$BACKUP_DATA_NAME'\", {useTypes: true, readLabels: true})"}]}' \
http://neo4j:7474/db/data/transaction/commit
printf "\nWaiting for APOC export..."
while [ ! -f /var/lib/neo4j/data/$BACKUP_DATA_NAME ]; do echo "backup data file does not exist, sleeping: /var/lib/neo4j/data/$BACKUP_DATA_NAME" && sleep 5; done
printf "\nTarring -> /var/lib/neo4j/data/$BACKUP_SCHEMA_NAME and /var/lib/neo4j/data/$BACKUP_DATA_NAME to /var/lib/neo4j/data/$BACKUP_NAME.tar"
tar -cvf "/var/lib/neo4j/data/$BACKUP_NAME.tar" -C "/var/lib/neo4j/data/" $BACKUP_SCHEMA_NAME $BACKUP_DATA_NAME
printf "Zipping -> /var/lib/neo4j/data/$BACKUP_NAME.tar.gz\n"
gzip -9 "/var/lib/neo4j/data/$BACKUP_NAME.tar"
printf "Zipped backup size:"
du -hs "/var/lib/neo4j/data/$BACKUP_NAME.tar.gz"
printf "Pushing /var/lib/neo4j/data/$BACKUP_NAME.tar.gz -> $BUCKET"
aws s3 cp "/var/lib/neo4j/data/$BACKUP_NAME.tar.gz" "$BUCKET"
printf "Cleaning up /var/lib/neo4j/data/graph.db-backup*"
rm /var/lib/neo4j/data/graph.db-backup*
env:
- name: BUCKET
value: {{ .Values.neo4j.backup.s3Path }}
volumeMounts:
- name: data
mountPath: /var/lib/neo4j/data
restartPolicy: Never
volumes:
- name: data
persistentVolumeClaim:
claimName: neo4j-pvc
{{- end}}
\ No newline at end of file
...@@ -18,3 +18,8 @@ config: ...@@ -18,3 +18,8 @@ config:
heap_initial_size: 23000m heap_initial_size: 23000m
heap_max_size: 23000m heap_max_size: 23000m
pagecache_size: 26600m pagecache_size: 26600m
neo4j:
backup:
enabled: false
s3Path: "s3://my-bucket/my-prefix"
schedule: "0 * * * *"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment