Are you looking to transition your Neo4j database from the cloud to a local environment? Perhaps you're considering backup options or simply need to work on your graph database locally. In this guide, we'll walk through the process of exporting a database from a cloud instance and importing it into a local instance using Neo4j Desktop.
Exporting from Cloud Database to Local Instance
-
Connect to the Cloud Instance from Neo4j Desktop Launch Neo4j Desktop and connect to your cloud instance.
-
Execute Cypher Query Once connected, open the Neo4j Browser and execute the following Cypher query:
CALL apoc.export.cypher.all(null, { format: "cypher-shell", stream:true, useOptimizations: {type: "UNWIND_BATCH", unwindBatchSize: 20} })
This query will generate Cypher code representing your entire database. The Cypher code will be between the
:begin
and:commit
statements in theCypherStatements
column of the response. -
Copy Cypher Code Copy the generated Cypher code and store it in a safe place. This code will be used to import the database into your local instance.
Importing to Local Database
-
Connect to Local Database Instance Launch Neo4j Desktop and connect to your local database instance.
-
Paste Cypher Code Paste the relevant sections of the copied Cypher code into the Neo4j Browser. These sections are delimited by
:begin
and:commit
. -
Execute Cypher Code Execute each segment of the Cypher code individually in the Neo4j Browser. Ensure that each segment runs successfully before proceeding to the next.
-
Verify Database After executing all Cypher code segments, execute the following query to verify the imported data:
MATCH (n) RETURN n
You should see the same graph structure as the cloud database in your local instance.
By following these steps, you can seamlessly migrate your Neo4j database from a cloud environment to a local instance. Whether you're transitioning between environments, performing backups, or simply need to work offline, Neo4j Desktop provides a convenient solution for managing your graph databases effectively.