Cover Image for Effortless Database Migration: Exporting from Cloud to Local Instance without Neo4j-Admin
Abdulrahman Muhialdeen
Abdulrahman Muhialdeen

Effortless Database Migration: Exporting from Cloud to Local Instance without Neo4j-Admin

Are you looking to transition your Neo4j database from the cloud to a local environment? Perhaps you're considering backup options...

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

  1. Connect to the Cloud Instance from Neo4j Desktop Launch Neo4j Desktop and connect to your cloud instance.

  2. 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 the CypherStatements column of the response.

  3. 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.

image

Importing to Local Database

  1. Connect to Local Database Instance Launch Neo4j Desktop and connect to your local database instance.

  2. Paste Cypher Code Paste the relevant sections of the copied Cypher code into the Neo4j Browser. These sections are delimited by :begin and :commit.

  3. 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.

  4. 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.