cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to Backup Neo4j

Hello! I am a beginner in Neo4j and I am carrying out a project in the area of Software Engineering with this database. In this moment of social isolation, I can no longer gather the team to work, so that the others have access to what I do I thought about the backup to send to them, but I don't know how to do it.
Can anyone help me with a step by step tutorial on how to make a backup on Neo4j? Explanatory images or video would help a lot ...

I wait ... Hugs to all!

1 ACCEPTED SOLUTION

Online backup is available only in Enterprise Edition, instructions here:

https://neo4j.com/docs/operations-manual/current/backup/performing/

For community, the best to backup is to fully stop the database, and then copy the data/databases folder, zipping it up. To restore you can unzip it in the right place, and restart the database. Do not take this kind of backup from community while the database is running.

View solution in original post

13 REPLIES 13

Online backup is available only in Enterprise Edition, instructions here:

https://neo4j.com/docs/operations-manual/current/backup/performing/

For community, the best to backup is to fully stop the database, and then copy the data/databases folder, zipping it up. To restore you can unzip it in the right place, and restart the database. Do not take this kind of backup from community while the database is running.

Hello. I did what you said, followed the steps and it didn't work. any idea what happens?

I gave two different sets of steps and I'm not sure which you followed. Additionally you haven't provided any details on what went wrong, so I can't help you further here. Recommend you open a new topic, and put in the steps you followed and what the exact console outputs were.

I managed to accomplish. I used data folder compression backup. Before, he was uncrossing in the wrong place.
Thanks a lot for the help!!

Hello David,

I tried to do a backup/restore from one container to another container using Docker version of Neo4j Community Edition 4.1.

  • Shut down container running Neo4j on server1
  • Copied the contents of the databases folder (had neo4j & system folders + store_lock file) and compressed to a tar.gz file
  • Uploaded the tar.gz file to server 2 and decompressed the contents to the same databases location
  • Attempted to start the new container on server 2 with the restored contents.
  • Neo4j shut down with the following error message:

Directories in use:
home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /logs
plugins: /var/lib/neo4j/plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
APOC couln't set a URLStreamHandlerFactory since some other tool already did this (e.g. tomcat). This means you cannot use s3:// or hdfs:// style URLs in APOC. This is caused by a limitation of the JVM which we cannot fix.

2020-09-03 21:23:18.441+0000 INFO Starting...
2020-09-03 21:23:20.620+0000 INFO ======== Neo4j 4.1.0 ========
2020-09-03 21:23:35.870+0000 ERROR Failed to start Neo4j on dbms.connector.http.listen_address, a socket address. If missing port or hostname it is acquired from dbms.default_listen_address. Error starting Neo4j database s
erver at /data/databases
java.lang.RuntimeException: Error starting Neo4j database server at /data/databases
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:198)
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.build(DatabaseManagementServiceFactory.java:158)
at org.neo4j.server.CommunityBootstrapper.createNeo(CommunityBootstrapper.java:36)
at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:117)
at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:87)
at org.neo4j.server.CommunityEntryPoint.main(CommunityEntryPoint.java:35)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.dbms.database.DefaultSystemGraphInitializer@78054f54' was successfully initialized, but failed to start. Please see the attached cause exceptio
n "Multiple components failed to initialize the system graph:
multi-database: org.neo4j.graphdb.DatabaseShutdownException: This database is shutdown.
security-users: org.neo4j.graphdb.DatabaseShutdownException: This database is shutdown.".
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:463)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110)

I was able to get it to work by also copying the transactions folder, but would prefer not to since it is much larger than the databases folder.

Is there a command you should run on your database prior to shutting it down and copying the databases folder to perhaps make this work without having to also copy the transactions folder?

You really shouldn't just copy files on disk to perform a backup, this is generally not a safe operation -- the use of the backup tool is recommended. That being said, the transaction log itself is governed by these settings here, and can be adjusted to make the TX log on disk as big or as small as you like.

https://neo4j.com/docs/operations-manual/current/configuration/transaction-logs/#:~:text=rotation.,l....

Obviously the smaller it is, the less history you're keeping, and the more trouble you're going to be in if you need to recover a store with an issue

I'm using the community edition of Neo4j. The backup tool is only available in the Enterprise edition. So the only way I know of to backup/restore is copying these files? Is that not correct for the community edition?

Even in the case of community, copying transaction files is not the right approach. The better way is to do offline load/dump like this:

https://neo4j.com/docs/operations-manual/current/tools/dump-load/

Hi David,

I've been trying to get this to work for several days without success. I'm using the community edition.

My process is:

  1. Stop the server
  2. Dump the neo4j database
  3. Start server
  4. Copy that dump to S3

Then to test the backup
5) Stop server
6) Pull down the dump from S3
7) Load dump into the same server and neo4j database (using force)
8) Start server

After doing this, whenever I use the browser to attempt to look at the database it says it is "offline"

Any ideas?

David

Thanks David.

The problem I had initially was I could not stop the database in my docker container. The STOP command is only available in the Enterprise Edition.

If you're running Neo4j in a docker container and want to perform an offline backup, you need to start the container without starting the normal Neo4j services. Then you can use the dump tool to perform a backup.

I found the solution mentioned here

I had this problem as well and ended up using the Bitnami Neo4j CE AMI instead of Docker on EC2. We were using the official Neo4j CE AMI but they stopped supporting it for EC2.

gclindsey
Node Clone
I was able to figure out how to backup Community Edition. Running Neo4j on EC2 using the ami bitnami-neo4j-4.4.6-0-linux-debian-10-x86_64:
 
# environment
export BITNAMI_NEO4J=/bitnami/neo4j
export BITNAMI_HOME=/home/bitnami
 
### backup ### 
# stop neo4j then run these steps
 
cd ${BITNAMI_NEO4J}/data/ && zip -r ${BITNAMI_HOME}/neo4j_bkp.zip databases/
result=$(aws s3 cp ${BITNAMI_HOME}/neo4j_bkp.zip s3://${DATA_BUCKET_NAME}/backups/neo4j/$$(date +'%Y/%m/%d/%H')/neo4j_bkp.zip) && \
echo $$result
rm ${BITNAMI_HOME}/neo4j_bkp.zip
 
# start neo4j

### restore from backup ###

# stop neo4j then run these steps
aws s3 cp s3://${DATA_BUCKET_NAME}/backups/neo4j/2022/10/12/18/neo4j_bkp.zip ${BITNAMI_HOME}/neo4j_bkp.zip
unzip -o ${BITNAMI_HOME}/neo4j_bkp.zip
cp -r databases/* ${BITNAMI_NEO4J}/data/databases/
chown -R neo4j:neo4j ${BITNAMI_NEO4J}/data/databases/ 
rm ${BITNAMI_HOME}/neo4j_bkp.zip
rm -r ${BITNAMI_HOME}/databases/
# start neo4j
 
The part that messed me up was to update the permissions when restoring the backup. I tested this by deleting all node then restoring to make sure they were available again.