Reserving the standalone version of neo4j on unix: mac or linux

I used to have a problem creating a "backup", as shown in this question , where I get an error when trying to restore a database, because I did a copy when the database started.

So, I did an experiment with a new database from another computer (this time with ubuntu) I tried this:

  • I created some nodes and relationships, very few, like 10 (example matrix).
  • Then I stopped the neo4j service
  • I copied the data folders containing graph.db to another location
  • After that, I deleted the graph.db folder and ran neo4j
  • He automatically created a new graph.db folder, and the database starts as new without any data, this is normal.
  • Then I stopped again and inserted the old graph.db folder

I get an error message:

Starting Neo4j Server...WARNING: not changing user waiting for server to be ready... Failed to start within 120 seconds. 

The error appears after 5 seconds, not after 120 seconds.

  • I tried pasting a folder called data strong>. The same error.

How do I manually backup and restore the neo4j community offline?

I read in some posts that you are copying and restoring, but this does not work.

thanks for the help

+7
database neo4j nosql backup
source share
3 answers

Online backup, in the sense of accepting a consistent backup when starting Neo4j, is only available in the corporate version of Neo4j. Backing up enterprise publications also contains a detailed check of the integrity of the backup, something that you also don’t get in the community.

The only safe option in the community edition is to turn off Neo4j and copy the graph.db folder recursively. I usually use:

 cd data tar -zcf graph.db.tar.gz graph.db/ 

To restore, you disconnect neo4j, empty the existing graph.db folder and restore the original graph.db folder from the backup:

 cd data rm -rf graph.db tar -zxf graph.db.tar.gz 
+28
source share

I also ran into this problem and wrote the following two codes:

Backup instant state

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 service neo4j
  • now=$(date +"%m_%d_%Y") = declare the current date as a variable
  • cd /var/lib/neo4j/data/databases/ = change directories to your neo4j directory where graph.db is located
  • tar -cvzf /var/backups/neo4j/$now.gb.tar.gz graph.db = make a compressed copy of the .db graph and save it in /var/backups/neo4j/$now.gb.tar.gz
  • service neo4j start = restart neo4j

Restore neo4j database from backup

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 service neo4j
  • cd /var/lib/neo4j/data/databases/ = change directories to your neo4j directory where graph.db is located
  • rm -r graph.db = delete the current graph.db and all its contents
  • tar 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 installed. Be sure to set the file name 10_25_2016.gb.tar.gz to what you called your file
  • service neo4j start = restart neo4j

Info : This seems to work for me, but since I don't have much experience with bash scripts, I doubt this is the best way. But I think it is clear and easy to set up :)

Greetings

+2
source share

If you cannot shut down and copy the file, you can write a cron script to get the data from Neo4j and save it in another database, for example mongodb. You can also write a cron script to restore.

This method is intended only for those who do not have money to buy a corporate version and not stop its server.

+1
source share

All Articles