Oftentimes you want to export a full (or partial) database to a file and import it again without copying the actual database files.
If you want to do the latter, use
Here are two ways on how to create a Cypher script file from your database or Cypher statement. This can also be used to downgrade (smaller) databases.
Some notes on the format written from these tools:
- recreate indexes and constraints
simple statements per node (
CREATE) / relationship (2x
optionally you can configure the export to use
data creation in batches (by default 40k) optionally surrounded with
- uses existing constraints for node-lookup
if no constraint on that label exist, use an artificial constraint + property (
UNIQUE IMPORT LABEL.
UNIQUE IMPORT ID) where the property value is the node-id, on node creation
- clean up artificial label + property + constraint at the end in batches
You can install the APOC procedure library.
And then use the
apoc.export.cypher.* procedures to create the
export.cypher file from your graph or data.
There is more in the documentation but below are some examples.
Those procedures have config options to generate formats for different outputs and also to split nodes, relationships and schema scripts into different files.
Please note that you have to enable the capability to write and read files first in
Import with cypher-shell
If you export the file with the
cypher-shell format, it contains the right syntax to use for transactions in the shell.
Then you can import them with
cat /tmp/export.cypher | ./bin/cypher-shell -u neo4j -p password