Home » Java » Enterprise Java » How to backup Neo4J on managed Kubernetes

About Sebastian Daschner

Sebastian Daschner
Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.

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-tools
cd 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 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.

1
2
3
4
5
6
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 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-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.

1
2
3
4
5
6
kubectl apply -f backup/neo4j-backup-job.yaml
 
kubectl get pods
 
NAME                       READY   STATUS      RESTARTS   AGE
neo4j-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.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments