How to backup Neo4J on managed Kubernetes
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.
In case you’re wondering how to deploy Neo4J to managed Kubernetes, have a look at the previous posts that show examples for clusters and single core instances.
Try it yourself
You’ll find the Kubernetes resources in the following GitHub repository.
1 2 3 | cd /tmp/git clone https://github.com/sdaschner/neo4j-toolscd neo4j-tools/ |
First, we create the persistent volume on which we store the backups later on:
1 | 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:
1 2 3 4 5 | kubectl get pvcNAME STATUS VOLUME STORAGECLASS AGEbackupdir-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.
1 2 3 4 5 6 | kubectl apply -f backup/neo4j-backup.yamlkubectl get podsNAME READY STATUS RESTARTS AGEneo4j-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 backupdir- volume.
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.
1 2 | kubectl delete pod neo4j-backupkubectl 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.
1 2 3 4 5 6 | kubectl apply -f backup/neo4j-backup-job.yamlkubectl get podsNAME READY STATUS RESTARTS AGEneo4j-backup-5ljhj 0/1 Completed 0 23s |
Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: How to backup Neo4J on managed Kubernetes (Video) Opinions expressed by Java Code Geeks contributors are their own. |




