0
votes

I have a data model that starts with a single record, this has a custom "recordId" that's a uuid, then it relates out to other nodes and they then in turn relate to each other. That starting node is what defines the data that "belongs" together, as in if we had separate databases inside neo4j. I need to export this data, into a backup data-set that can be re-imported into either the same or a new database with ease

After some help, I'm using APOC to do the export:

call apoc.export.cypher.query("MATCH (start:installations)
WHERE start.recordId = \"XXXXXXXX-XXX-XXX-XXXX-XXXXXXXXXXXXX\"
CALL apoc.path.subgraphAll(start, {}) YIELD nodes, relationships
RETURN nodes, relationships", "/var/lib/neo4j/data/test_export.cypher", {})

There are then 2 problems I'm having:

Problem 1 is the data that's exported has internal neo4j identifiers to generate the relationships. This is bad if we need to import into a new database and the UNIQUE IMPORT ID values already exist. I need to have this data generated with my own custom recordIds as the point of reference.

Problem 2 is that the import doesn't even work.

call apoc.cypher.runFile("/var/lib/neo4j/data/test_export.cypher") yield row, result

returns:

Failed to invoke procedure apoc.cypher.runFile: Caused by: java.lang.RuntimeException: Error accessing file /var/lib/neo4j/data/test_export.cypher

I'm hoping someone can help me figure out what may be going on, but I'm not sure what additional info is helpful. No one in the Neo4j slack channel has been able to help find a solution.

Thanks.

1
At the risk of being obvious, have you verified that that path exists on the neo4j server's computer system?cybersam
Yes, the path exists and the export put the file there initially prior to attempting to restore it. I literally ran one, then the other with the file name/path copied and pasted into both. I couldn't find any reason for the export to successfully work and the import have trouble accessing the file.Alex Liffick

1 Answers

0
votes

problem1: The exported file does not contain any internal neo4j ids. It is not safe to use neo4j ids out of the database, since they are not globally unique. So you should not use them to transfer data from one database to another. If you are about to use globally uniqe ids, you can use an external plugin like GraphAware UUID plugin. (disclaimer: I work for GraphAware)

problem2: If you cannot access the file, then possible reasons:

  • apoc.import.file.enabled=true is not set in neo4j.conf
  • os level permission is not set