Neo4J Offline-Backups
This tutorial explains how to carry out an offline backup of your Neo4J database in a kubernetes cluster.
An offline backup requires the Neo4J database to be stopped. Read the docs. Neo4J also offers online backups but this is available in enterprise edition only.
The tricky part is to stop the Neo4J database without stopping the container. Neo4J's docker container image starts neo4j
by default, so we have to override this command with sth. that keeps the container spinning but does not terminate it.
Stop and Restart Neo4J Database in Kubernetes
This tutorial explains how to keep a docker container running. For kubernetes, the way to override the docker image CMD
is explained here.
So, all we have to do is edit the kubernetes deployment of our Neo4J database and set a custom command
every time we have to carry out tasks like backup, restore, seed etc.
First bring the application into maintenance mode to ensure there are no database connections left and nobody can access the application.
Run the following:
Add the following to spec.template.spec.containers
:
and write the file which will update the deployment.
The command tail -f /dev/null
is the equivalent of sleep forever. It is a hack to keep the container busy and to prevent its shutdown. It will also override the default neo4j
command and the kubernetes pod will not start the database.
Now perform your tasks!
When you're done, edit the deployment again and remove the command
. Write the file and trigger an update of the deployment.
Create a Backup in Kubernetes
First stop your Neo4J database, see above. Then:
Revert your changes to deployment nitro-neo4j
which will restart the database.
Restore a Backup in Kubernetes
First stop your Neo4J database. Then:
Revert your changes to deployment nitro-neo4j
which will restart the database.
Last updated