Neo4J Database Backup - noduslabs/infranodus GitHub Wiki

Before backing up Neo4J database it has to be stopped completely. Otherwise you are risking getting incomplete data and you won't be able to recover it easily. (See InfraNodus Wiki on how it can be done anyway).

The enterprise version of Neo4J has backup mechanism embedded but the community version does not.

So the sequence of the steps to follow therefore with the community version is:

  1. Disable to shell script that relaunches neo4j if you have one.

That script is usually made to ensure the database relaunches if it's down and is ran by a cron:

#!/bin/bash -l`
#/path/to/neo4j/on/your/server/bin/neo4j start

The the second line commented it's not going to run. So the database won't be relaunched.

  1. Then stop the Neo4J database:

stop neo4j

If you don't stop the DB your backup will be incomplete.

  1. Verify it's stopped:

neo4j status

  1. Then go to the /data/databases folder of your Neo4J installation and verify graph.db is there. You can check its size by:

du -h graph.db

Then launch the tar command to archive the folder and all its contents: tar -zcf graph.db.tar.gz graph.db/ --checkpoint=10000 --checkpoint-action="echo=Hit %s checkpoint #%u"

In this command the -zcf flag says to zip all the contents of all the folders, then we have the file name, then the folder which should be archived. The --checkpoint flags just give us the feedback during the process, every 10000 bytes, so we know what's up and that the tar process is not stalled.

  1. Once this is finished, verify the size of the archive ls -l then launch the Neo4J database neo4j start and finally uncomment the automatic launch bash script as in point 1.

You can also verify the archive tar -tvf graph.db.tar.gz

  1. Once the DB creation is complete verify its size ls -l in the folder and then copy it to a server of your choice:

scp -r graph.db.tar.gz username@server:~/graph.db.tar.gz