2

I have to move data between two Neo4j databases. One of them is older (2.1.8) and the new one is 2.3.0. What I tried is this, but you can see also in the output that something is wrong.

/home/adam/neo4j-community-2.1.8/bin/neo4j-shell -path /home/adam/neo4j_bak9/ -c "dump" | /home/adam/neo4j-community-2.3.0/bin/neo4j-shell -file -
Transaction started
3 ms

WARNING: Invalid input 'c': expected whitespace, comment, ';' or end of input (line 2, column 1 (offset: 39))
"create index on :`Location`(`latitude`)"
 ^
ERROR (-v for expanded information):
    Transaction was marked as successful, but unable to commit transaction so rolled back.

 -host      Domain name or IP of host to connect to (default: localhost)
 -port      Port of host to connect to (default: 1337)
 -name      RMI name, i.e. rmi://<host>:<port>/<name> (default: shell)
 -pid       Process ID to connect to
 -c         Command line to execute. After executing it the shell exits
 -file      File containing commands to execute, or '-' to read from stdin. After executing it the shell exits
 -readonly  Connect in readonly mode (only for connecting with -path)
 -path      Points to a neo4j db path so that a local server can be started there
 -config    Points to a config file when starting a local server

Example arguments for remote:
    -port 1337
    -host 192.168.1.234 -port 1337 -name shell
    -host localhost -readonly
    ...or no arguments for default values
Example arguments for local:
    -path /path/to/db
    -path /path/to/db -config /path/to/neo4j.config
    -path /path/to/db -readonly

It look that neo4j is producing syntax that could not be read by the new version. Am I doing something wrong or this is a bug?

1 Answer 1

3

That's a problem that I've had. I think that it's expecting semi-colons (or vice versa) for the create index statements at the top of the dump. It's sad that it's not more of a smooth import/export there.

Another option for the easiest and cleanest way of upgrading Neo4j (assuming you're able to have a bit of downtime):

  • Shut down both servers
  • Copy the graph.db dir from the old data dir to the new one
  • Make sure that the new database has allow_store_upgrade=true set in the conf/neo4j.properties file
  • Start up the new database

When it starts up, it should see that the database files are from an old version and automatically upgrade them to the 2.3.0 format.

Sign up to request clarification or add additional context in comments.

4 Comments

some time ago I've created a script that cares about downloads itself and performs the upgrades: blog.armbruster-it.de/2012/06/…
I wrote an shell-extension that does a proper export: github.com/jexp/neo4j-shell-tools#cypher-export
The idea with copying the old database to the new location and setting allow_store_upgrade was my first one. However, there was problem with that. I solved it by going 2.1.8 -> 2.2.6 -> 2.3.0. Still, it is a good thing to have, a simple way to dump database and then load it without additional tools. Original idea looked promising. It is sad that because of this small issue it is not possible. I hope that it is compatible at least 2.3.0 <-> 2.3.0.
Interesting, I thought you could skip major versions. Maybe it's just some cases where you can't. Glad it worked out for you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.