Consistency checker
You can use the neo4j-admin database check
command to check the consistency of a database, a dump, or a backup.
The neo4j-admin
tool is located in the /bin directory.
Syntax
The neo4j-admin database check
command has the following syntax:
neo4j-admin database check [-h] [--expand-commands] [--force] [--verbose]
[--check-counts[=true|false]] [--check-graph[=true|false]]
[--check-indexes[=true|false]] [--check-property-owners[=true|false]]
[--additional-config=<file>] [--max-off-heap-memory=<size>]
[--report-path=<path>] [--threads=<number of threads>]
[[--from-path-data=<path> --from-path-txn=<path>] | [--from-path=<path> [--temp-path=<path>]]]
<database>
Description
This command allows for checking the consistency of a database, a dump, or a backup. It cannot be used with a database that is currently in use.
Some checks can be quite expensive, so it may be useful to turn some of them off for very large databases. Increasing the heap size might be a good idea.
It is not recommended to use an NFS to check the consistency of a database, a dump, or a backup as this slows the process down significantly. |
Parameters
Parameter | Description |
---|---|
|
Name of the database to check. |
Options
The neo4j-admin database check
command has the following options:
Option | Description | Default |
---|---|---|
|
Enable verbose output. |
|
|
Show this help message and exit. |
|
|
Allow command expansion in config value evaluation. |
|
|
Configuration file with additional configuration. |
|
|
Force a consistency check to be run, despite resources, and may run a more thorough check. |
|
|
Perform consistency checks on indexes. |
|
|
Perform consistency checks between nodes, relationships, properties, types, and tokens. |
|
|
Perform consistency checks on the counts. Requires <check-graph>, and may implicitly enable <check-graph> if it were not explicitly disabled. |
|
|
Perform consistency checks on the ownership of properties. Requires <check-graph>, and may implicitly enable <check-graph> if it were not explicitly disabled. |
|
|
Path to where a consistency report will be written. Interpreted as a directory, unless it has an extension of |
|
|
Maximum memory that |
|
|
Number of threads used to check the consistency. |
|
|
Path to the databases directory, containing the database directory to source from. |
|
|
Path to the transactions directory, containing the transaction directory for the database to source from. |
|
|
Path to the directory containing dump/backup artifacts that need to be checked for consistency. If the directory contains multiple backups, it will select the most recent backup chain, based on the transaction IDs found, to perform the consistency check. |
|
|
Path to directory to be used as a staging area to extract dump/backup artifacts, if needed. |
|
As of Neo4j 5.19, the |
Output
If the consistency checker does not find errors, it exits cleanly and does not produce a report.
If the consistency checker finds errors, it exits with an exit code other than 0
and writes a report file with a name in the format inconsistencies-YYYY-MM-DD.HH24.MI.SS.report
.
The location of the report file is the current working directory, or as specified by the parameter report-path
.
Example
Run the consistency checker
Note that the database must be stopped first.
bin/neo4j-admin database check neo4j Running consistency check with max off-heap:618.6MiB Store size:160.0KiB Allocated page cache:160.0KiB Off-heap memory for caching:618.5MiB ID Generator consistency check .................... 10% .................... 20% .................... 30% .................... 40% .................... 50% .................... 60% .................... 70% .................... 80% .................... 90% .................... 100% Index structure consistency check .................... 10% .................... 20% .................... 30% .................... 40% .................... 50% .................... 60% .................... 70% .................... 80% .................... 90% .................... 100% Consistency check .................... 10% .................... 20% .................... 30% .................... 40% .................... 50% .................... 60% .................... 70% .................... 80% .................... 90% .................... 100%
Run with the --from-path
option to check the consistency of a backup or a dump.
bin/neo4j-admin database check --from-path=<directory-with-backup-or-dump> neo4j
|
Check a backup stored in an AWS S3 storage
This feature is available from Neo4j 5.19.
To check data stored in an AWS S3 storage, you can use the --from-path
option with S3 URIs.
For example, use the following steps.
Neo4j uses the AWS SDK v2 to call the APIs on AWS using AWS URLs.
Alternatively, you can override the endpoints so that the AWS SDK can communicate with alternative storage systems, such as Ceph, Minio, or LocalStack, using the system variables |
-
Ensure that the AWS CLI is installed and configured with the necessary credentials.
-
Install the AWS CLI by following the instructions in the AWS official documentation — Install the AWS CLI version 2.
-
Use
aws configure
command to set youraws_access_key_id
andaws_secret_access_key
from AWS. -
Create an S3 bucket and a directory to store the backup files using the AWS CLI:
aws s3 mb --region=us-east-1 s3://myBucket aws s3api put-object --bucket myBucket --key myDirectory/
For more information on how to create a bucket and use the AWS CLI, see the AWS official documentation — Use Amazon S3 with the AWS CLI and Use high-level (s3) commands with the AWS CLI.
-
Verify that the
~/.aws/config
is correct by running the following command:cat ~/.aws/config
The output should look like this:
[default] region=eu-north-1
-
Verify that the
~/.aws/credentials
is correct:cat ~/.aws/credentials
The output should look like this:
[default] aws_access_key_id=this.is.secret aws_secret_access_key=this.is.super.secret
-
-
Run the
bin/neo4j-admin database check
command to check the consistency of your database from the AWS S3 storage:bin/neo4j-admin database check <database> --from-path=s3://myBucket/myDirectory/myBackup.backup