How to import a Neo4j database dump
Dumps are provided to TIB members only. This may change in the future. Or not. |
You can re-load / setup a database dump with the reload-dump script in the scripts directory.
The following section is still relevant if you want to understand what is happening there.
To load a dump, place it in the dumps directory and name it neo4j-dump-latest.dump (or use a symlink) or pass the filename of the dump you want to load as the first command line argument to the script.
|
Sometimes it is helpful to work on a production database dump, e.g. for debugging. To make that work with the Neo4j Community Edition and Docker, a workflow similar to the one below can be used.
-
Create a named volume for the dumps. (This only needs to be done once.) It allows us to store multiple versions of dumps to choose from but use the same workflow for importing.
docker volume create orkg-dumps
-
Copy a dump to the volume. This uses a temporary container called
dummy
to mount the volume. It will be deleted after copying.alpine
is a very small Linux distribution. The Docker image itself does not matter much, but it is preferred to use something small.We assume the dump to be named
neo4j-dump-YYYYMMDD.dump
and to reside in the current directory. You may need to adjust this to your situation.docker container create --name dummy --volume orkg-dumps:/dumps alpine docker cp neo4j-dump-YYYYMMDD.dump dummy:/dumps docker rm dummy
-
Shut down all running ORKG containers. (The only container that needs to be stopped is
neo4j
, but we want to be sure.)docker-compose down
-
Import the dump into Neo4j. We will create a temporary Neo4j container from which we load the dump. Importing the dump will be done interactively from a shell inside the container. It needs to be forced because the database already exists and contains data.
You also need to leave the container afterwards. This can be done by typing
exit
or pressing kbd:[Ctrl+d].docker run -it --rm --entrypoint /bin/bash --volumes-from orkg-backend_neo4j_1 --volume orkg-dumps:/dumps neo4j:3.5 neo4j-admin load --from=/dumps/neo4j-dump-YYYYMMDD.dump --force # Type "exit" or press Ctrl+d
You should be back at your normal command-line prompt.
-
Start everything back up. The Neo4j container should now contain the data of the dump.
docker-compose up -d