Unverified Commit 12837093 authored by Adam Boscarino's avatar Adam Boscarino Committed by GitHub

add one-off pod and documentation for restoring neo4j backup (#394)

parent cfd609d7
# Restoring neo4j Backups
The Amundsen Helm chart includes a Kubernetes CronJob that backs up the neo4j database to S3. If you need to restore from one of these backups, use the one-off pod in this directory.
## Create the Pod
You should have setup `kubectl` for the Kubernetes cluster you wish to restore in before running these commands.
Update the YAML file with the S3 Bucket for the backup you wish to restore and then apply the pod.
```shell
kubectl apply -n <your-namespace> -f restore-neo4j-pod.yaml
```
Once the pod has been created, it will automatically run the restore. You can check the pod's logs to see whether it has succeeded for failed.
apiVersion: v1
kind: Pod
metadata:
name: restore-neo4j-from-latest
spec:
containers:
- name: restore-neo4j-from-latest
image: neo4j:3.3.0
command:
- "/bin/sh"
- "-c"
- |
apk -v --update add --no-cache --quiet curl python py-pip && pip install awscli -q
latest_backup=$(aws s3api list-objects-v2 --bucket "$BUCKET" --query 'reverse(sort_by(Contents, &LastModified))[:1].Key' --output=text)
aws s3 cp s3://$BUCKET/$latest_backup /tmp
tar -xf /tmp/$latest_backup -C /
data_file=`ls /data|grep \.data`
schema_file=`ls /data|grep \.schema`
./bin/neo4j-shell -host neo4j -file /data/$schema_file
echo "CALL apoc.import.graphml('/data/$data_file', {useTypes: true, readLabels: true});" | /var/lib/neo4j/bin/neo4j-shell -host neo4j
env:
- name: BUCKET
value: s3://dev/null
volumeMounts:
- name: data
mountPath: /data
restartPolicy: OnFailure
volumes:
- name: data
persistentVolumeClaim:
claimName: neo4j-pvc
\ No newline at end of file
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