In this article, we will talk about Neo4j backup and restore operations.
Neo4j Offline Backup
Let’s take Offline backup of Neo4j Graph Database.
It is backed up using Neo4j’s admin tool and the service must be stopped for offline backup.
Sytanx:
1 |
[sudo] neo4j-admin dump --database=db-folder --to=db-target-folder/db-dump-file |
db-target-folder: We write the path information to get dump.
db-dump-file: We enter the name of dump file.
Example
Let’s perform these steps for our own neo4j database:
1 2 |
[root@localhost /]# cd /var/lib/neo4j/data/databases/ [root@localhost /]# ls -la |
As you can see, we have accessed our database name.
Database Name: graph.db
We prepared our script using the neo4j-admin tool as below.
1 |
sudo /usr/bin/neo4j-admin dump --database=graph.db --to=/usr/local/backup/graphDb_2019-07-17.dump |
We have successfully backed up our database(as dump).
Let’s go to the folder and check the dump.
1 |
cd /usr/local/backup/ |
Neo4j Load Dump Backup(Restore)
At this stage, we will learn how to restore Neo4j Graph Database dumps.
Let’s restore Dump step by step.
Sytanx:
1 |
neo4j-admin load --from=<archive-path> --database=<database> [--force] |
database: database information to restore dump
Example:
Let’s perform this step for our own neo4j dump we created above:
1 |
[root@localhost /]# sudo /usr/bin/neo4j-admin load --from=/usr/local/backup/graphDb_2019-07-17.dump --database=graph.db --force |