Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restoring to a neo4j docker container

Tags:

docker

neo4j

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.

like image 371
luoyang9 Avatar asked Dec 31 '25 00:12

luoyang9


1 Answers

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.

like image 164
Bram Avatar answered Jan 04 '26 15:01

Bram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!