Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get dump from a neo4j in docker?

Tags:

docker

neo4j

docker run -d -v /home/data:/data --name=neo neo4j

after I run a neo4j in docker,
docker exec -it neo bash

./neo4j-admin  dump --database=graph.db --to=/home/2018.dump

it will say neo4j is running
command failed: the database is in use -- stop Neo4j and try again

but ./neo4j stop will get neo4j not running

what should i do?

like image 419
Veiasai Avatar asked Jul 27 '18 05:07

Veiasai


People also ask

How do I stop Neo4j in my container?

If executing from the same terminal as the docker process, use Ctrl-C which will stop the neo4j docker container process.

What is docker Neo4j?

Neo4j is a highly scalable, robust native graph database. docker pull neo4j.


1 Answers

I had the same issue before, so I wrote this workaround to dump neo4j data and pull it outside the container to the host machine.

docker rm --force neo4j-dump

docker run \
--name neo4j-dump \
--env-file /storage/bin/.neo4j.env \
--mount type=bind,source=<neo4j_data_folder>,target=/data \
neo4j bin/neo4j-admin dump --database=graph.db --to=/graph.db.dump

docker cp `docker ps -aqf "name=neo4j-dump"`:/graph.db.dump <target_dump_file>

docker rm --force neo4j-dump

This will create a new container and dump data instead of starting neo4j service, then copy the dump to the host, just update and to yours

like image 119
Khaled AbuShqear Avatar answered Oct 14 '22 18:10

Khaled AbuShqear