Knowledge Base

Four ways to check the consistency of a Neo4j graph

When it comes checking the inconsistencies in your graph, there are four methods to do. This article describes them below:

1. The easiest approach is it to utilize the check-consistency=true option with the backup command. With this approach your graph stays online and the consistency check is done along with the scheduled or adhoc backup.

neo4j-home> bin/neo4j-admin backup --backup-dir=/home/backups --name=graph.db --check-consistency=true

2. If you are not checking the consistency through the backup command, then you will need to stop Neo4j to check its consistency.

neo4j-home> bin/neo4j stop
neo4j-home> bin/neo4j-admin check-consistency --database=graph.db

3. There will be situations when you would want to test the consistency of a backup. Here is how that is done:

neo4j-home> bin/neo4j-admin check-consistency --backup=/<path-to-backup-dir>/<graph_backup.db>

4. Using the dump and load commands is the recommended, and safe, way of transferring databases between environments. It is possible to check the consistency of an offline dump.

Assume you have the dump file sitting in: /mnt/dump_of_dbs

  • The dump file is a gzip file. To confirm the format, perform these commands:

    $ cd /mnt/dump_of_db
    $ file graph.db.dump
    graph.db.dump: gzip compressed data

You will see that the .dump file is a gzip file.

  • Create a directory under mnt/dump_of_dbs

    $ mkdir graph.db
  • Uncompress the gzip file under the graph.db directory:

    $ cd graph.db
    ~/dump_of_dbs/graph.db$ tar xvzf ../graph.db.dump
  • Finally, run the consistency check as:

    neo4j-home> bin/neo4j-admin check-consistency --backup=/mnt/dump_of_dbs/graph.db

End Notes: