How to backup Neo4J on managed Kubernetes (Video)saturday, june 06, 2020
In the following video I’ll explain how to take full and incremental backups of Neo4J instances that run in a managed Kubernetes environment. We’ll use additional pods to take remote backups and store the backup data on persistent volumes which are provided by our managed environment.
Try it yourself
You’ll find the Kubernetes resources in the following GitHub repository.
cd /tmp/ git clone https://github.com/sdaschner/neo4j-tools cd neo4j-tools/
First, we create the persistent volume on which we store the backups later on:
kubectl apply -f backup/neo4j-backup-pvc.yaml
This will create a volume claim for our backup volume, which is created by our storage provider. After a few moments we should have an additional persistent volume:
kubectl get pvc NAME STATUS VOLUME STORAGECLASS AGE backupdir-graphdb-neo4j-core-0 Bound pvc-072c4f08-[...] ibmc-file-gold 2m20s [...]
Now we can create our backup pod which remotely connects to our Neo4J instance, in my example the
core-0 instance, to take a full backup.
kubectl apply -f backup/neo4j-backup.yaml kubectl get pods NAME READY STATUS RESTARTS AGE neo4j-backup 0/1 Completed 0 23s
If we have a look at the pods log output, we’ll see that it took a full backup of our Neo4J instance, similar to what’s shown in the video.
The pod bound our
Now, if we remove the finished pod and create a new one, from the same YAML description, we’ll see that it will only take an incremental backup, since it will bind the same persistent volume and notice the existing backup.
kubectl delete pod neo4j-backup kubectl apply -f backup/neo4j-backup.yaml
The pod log output will show that now only an incremental backup has been taken.
For a more managed way to create these backup pods, you can use the following Kubernetes job, which will create a pod, similar to how a Kubernetes replica set manages its pods.
kubectl apply -f backup/neo4j-backup-job.yaml kubectl get pods NAME READY STATUS RESTARTS AGE neo4j-backup-5ljhj 0/1 Completed 0 23s
Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: