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:
- Disable to shell script that relaunches
neo4jif 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.
- Then stop the Neo4J database:
stop neo4j
If you don't stop the DB your backup will be incomplete.
- Verify it's stopped:
neo4j status
- Then go to the
/data/databasesfolder of your Neo4J installation and verifygraph.dbis 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.
- Once this is finished, verify the size of the archive
ls -lthen launch the Neo4J databaseneo4j startand finally uncomment the automatic launch bash script as in point 1.
You can also verify the archive tar -tvf graph.db.tar.gz
- Once the DB creation is complete verify its size
ls -lin the folder and then copy it to a server of your choice:
scp -r graph.db.tar.gz username@server:~/graph.db.tar.gz