luoyang9
luoyang9

Reputation: 55

Restoring to a neo4j docker container

I have a docker container running neo4j on my server, and I have automated backups set up to backup the database. I tried to test restoring the database from a backup, but I can't figure out how to restore the database inside a docker container.

I'm trying to use docker exec -t bin/neo4j-admin restore --from=/path/to/backup --database=graph.db --force

I read from the neo4j docs you have to shut down neo4j to restore a backup, but I'm pretty sure shutting down neo4j in the container will shut down my container (the container is started using bin/neo4j console). Is there a way to restore backups without shutting down neo4j, or a way to shut down neo4j without shutting down the container? Or do I have to just run neo4j without docker directly on my server?

Right now, the only solution that works is copying the backup's graph.db folder into the actual data folder, but I don't think that's the correct way.

Upvotes: 3

Views: 1409

Answers (2)

Larry C.
Larry C.

Reputation: 21

Found an easier way to change the default database for your Docker Neo4J container, you can simply set an environment variable in your docker run or service command:

-e NEO4J_dbms_active__database="test.db"

Upvotes: 2

Bram
Bram

Reputation: 51

I ran into the same problem. Eventually I used neo4j-admin restore on a running neo4j container, using a new database name, eg. --database=new.db. Then stopped the instance and changed dbms.active_database=graph.db to dbms.active_database=new.db in neo4j.conf (This only works if you have the config file in a mounted volume. As far as I know there is no environment variable available to set the active database). Still this is not the most convenient solution, so I hope there is a better way to do it.

Upvotes: 2

Related Questions