9

Does any one know how to migrate data from one instance of Neo4j to another. To be more precise, I want to know, how to move the data from one instance of Neo4j on my local machine to another on remote machine. Does any one have any idea about it.

I'm working on my windows machine with Eclipse and Embedded Neo4j . I need to transfer this data to remote Neo4j instance on a Centos machine. Please help me with this.

4 Answers 4

7

Not sure how to do it for "embedded neo4j db". But for standalone and in case you have something like the command line tool "Putty" on your windows machine, this should work. Instead of $NEO4j_HOME you can also use the normal path without the env variable.

$NEO4J_HOME/bin/neo4j stop

cd $NEO4J_HOME/data
tar -cvf graph.db.tar graph.db
gzip graph.db.tar

scp -i ~/some_path/key_for_remote_server.pem ./graph.db.tar.gz username@your_remote_domeain.com:~/

ssh -i ~/some_path/key_for_remote_server.pem/ username@your_remote_domeain.com

On your remote server (at least this works for ubuntu): Maybe you need to use "sudo" (prefix the commands with sudo).

mv ./graph.db.tar.gz /some_path/
cd /some_path/
gunzip graph.db.tar.gz
tar -xvf graph.db.tar

$NEO4J_HOME/bin/neo4j start
$NEO4J_HOME/bin/neo4j status
2
  • could you please give me any hints for how to do it when the source is Embedded Neo4j. I even don't understand where the data is stored, when I use embedded nEO4J.I created data in Embedded Neo4j,and then I went into browser , accessing the same Data base, I couldn't find the data that is created through embedded Neo4j. Please help me out
    – Vineel
    Feb 8, 2014 at 2:36
  • I've never used embedded neo4j and don't intennd to use it. So can't elaborate on that.
    – Roman
    Feb 9, 2014 at 8:12
3

You can migrate the data by using the apoc procedure by running the below query in the cypher shell from where the data needs to be exported:

CALL apoc.export.cypher.all('myfilename.cypher');

This will download the file with cypher queries in the import folder

Go the database instance where the data needs to be imported and copy the file in the import folder. Run the below command using the cypher shell:

apoc.cypher.runFile("myfilename.cypher",{}) yield row, result;

For more advanced options follow the below links:

2

I found out the following workaround for copying the data from a server in the cluster to all others, after using the neo4j-import tool:

  1. Stop all nodes.

  2. On the new node/server, where you need your data to be copied, you have to create the database folder for that graph (in my case loadTest): /neo4j-enterprise-3.1.0/data/databases/loadTest.db

  3. Then, the source node/server that is holding the data, you have to copy here the neostore.id file to the destination server db folder (loadTest.db from the previous step).

  4. Start all nodes. In the background neo4j will copy data from other cluster servers to the new node.

1

For embedded mode , you would just need to locate the graph neo4j-db folder location then zip and send it to the remote system.

In your code where you would have called graphdatabaseservice , you would have given the target location

Check if its relative path then the database might be in your project folder .

Now for running the db instance on browser , you will need to use the neo4j communty server and point it to the folder containing the index folder. So if your neo4j-db is located at $project/tmp/neo4j-db then you will give the file path till this folder(the index folder will be inside this folder)

Edit

The folder that will contain the schema and index folders needs to be zipped. You can upload and unzip the folder at a certain location using Putty on your standalone server. Then just change the org.neo4j.server.database.location in conf/neo4j-server.properties file.

8
  • Not very clear..I 'm converting relational data into graph type data using Java code on windows machine in Embedded-Neo4j. After this process is over, i would need to migrate this entire thing into proper Neo4j(NonEmbedded server, lets say on the same machine). How can we achieve this ?
    – Vineel
    Feb 8, 2014 at 5:45
  • Which folder, do I need to zip and send ,could you please tell me that thing precisely. Please consider.
    – Vineel
    Feb 8, 2014 at 5:55
  • Why do we even need to change the property org.neo4j.server.database.location. Its value is data/graph.db . If I understand correctly, if in my Java code, I am pointing to folder X in the constructor newEmbeddedDatabaseBuilder, then I would need to move entire X to the remote server . So far am I correct and then, I dont understand why do we need to change the property org.neo4j.server.database.location, its just relative path rightThough we change the whole folder(X) location,it remains same, doesn't it .Please let me know.
    – Vineel
    Feb 8, 2014 at 8:24
  • You would be unzipping the content to a specific location on the standalone server. The conf of your server should point to the location where you unzipped. Feb 8, 2014 at 8:26
  • org.neo4j.server.database.location As I said , the value of the property is data/graph.db, which is relative path. Even when I change the entire location of X to new machine, that remains same right? May be,am I missing some thing here ..
    – Vineel
    Feb 8, 2014 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.