Previously I had a problem when making a \'backup\' as shown in this question where I get an error when trying to restore the database because I did a copy when the database
If you cant shutdown and copy the file then you can write a cron script to fetch the data from Neo4j and store it in some other database , say mongodb. You can write cron script to restore also.
This method is only for those who dont have money to buy enterprise edition and cant shutdown his server .
Online backup, in a sense of taking a consistent backup while Neo4j is running, is only available in Neo4j enterprise edition. Enterprise edition's backup also features a verbose consistency check of the backup, something you do not get in community either.
The only safe option in community edition is to shutdown Neo4j cleanly and copy away the graph.db folder recursively. I'm typically using:
cd data
tar -zcf graph.db.tar.gz graph.db/
For restoring you shut down neo4j, clean out a existing graph.db folder and restore the original graph.db folder from your backup:
cd data
rm -rf graph.db
tar -zxf graph.db.tar.gz
I also ran into this issue and wrote following two codes:
service neo4j stop && now=$(date +"%m_%d_%Y") && cd /var/lib/neo4j/data/databases/ && tar -cvzf /var/backups/neo4j/$now.gb.tar.gz graph.db && service neo4j start
service neo4j stop
= stop the neo4j servicenow=$(date +"%m_%d_%Y")
= declare the current date as variablecd /var/lib/neo4j/data/databases/
= change directories to your neo4j dir where the graph.db is locatedtar -cvzf /var/backups/neo4j/$now.gb.tar.gz graph.db
= make a compressed copy of the graph.db and save it to /var/backups/neo4j/$now.gb.tar.gz
service neo4j start
= restart neo4j
service neo4j stop && cd /var/lib/neo4j/data/databases/ && rm -r graph.db && tar xf /var/backups/neo4j/10_25_2016.gb.tar.gz -C /var/lib/neo4j/data/databases/ && service neo4j start
service neo4j stop
= stop the neo4j servicecd /var/lib/neo4j/data/databases/
= change directories to your neo4j dir where the graph.db is locatedrm -r graph.db
= remove the current graph.db and all its contentstar xf /var/backups/neo4j/10_25_2016.gb.tar.gz -C /var/lib/neo4j/data/databases/
= Extract the backup to the directory where the old graph.db was located. Be sure to adjust the filename 10_25_2016.gb.tar.gz
to what you called your fileservice neo4j start
= restart neo4jInfo: This seems to work for me but as I do not have alot of experience with bash scripting I doubt this is the optimal way. But I think it is understandable and easy to customize :)
Cheers