How to load dump file in neo4j running inside docker?

Viewed 25

I tried a couple of things but none seem to have worked.

I used the following command to copy the dump file into the container.

docker cp ./db.dump a2198b1e36e5:/var/lib/neo4j/import/db.dump

And then I used the following to load it into the db.

docker run --interactive --tty --rm \
    --volume=$HOME/neo4j/data:/data \ 
    --volume=$HOME/neo4j/backups:/backups \ 
    neo4j/neo4j-admin:4.4.9 \
neo4j-admin load --database=neo4j --from=/var/lib/neo4j/import/db.dump

But it threw and exception that the database must be stopped before loading the dump file.

Interestingly enough I can't stop the database because it's not enterprise version.

STOP DATABASE neo4j; // fails with error "Unsupported administrative command.."

1 Answers

For the community version the easiest way I found of doing this is to restore a database with a name other than neo4j.

neo4j-admin load --database=dumpdatabase--from=/var/lib/neo4j/import/db.dump

Then you stop the docker container, and run it with the default database env variable.

docker run --interactive --tty --rm \
    --volume=$HOME/neo4j/data:/data \ 
    --volume=$HOME/neo4j/backups:/backups \ 
    --env NEO4J_default__database=dumpdatabase \
    neo4j/neo4j-admin:4.4.9

I should note that you should persist the data folder for this solution, which you already do.

Related