7.4. Perform a backup

This section describes how to perform a backup of a Neo4j database.

This section includes:

7.4.1. Backup commands

A Neo4j database can be backed up in online mode, using the backup command of neo4j-admin.


neo4j-admin backup --backup-dir=<backup-path> --name=<graph.db-backup>
                    [--from=<address>] [--protocol=<any|catchup|common>]


Option Default Description



Directory to place backup in.



Name of backup. If a backup with this name already exists an incremental backup will be attempted.



Host and port of Neo4j.



Protocol over which to perform backup. If set to any, then catchup will be tried first. If that fails, then it will attempt to fall back to common. It is recommended to set this option explicitly. Set it to catchup for Causal Cluster backups, and to common for HA or single-instance backups. For more information, see Section 7.3.6, “Backup scenarios and examples”.



If an incremental backup fails backup will move the old backup to <name>.err.<N> and fallback to a full backup instead.



The size of the page cache to use for the backup process.



Timeout in the form <time>[ms|s|m|h], where the default unit is seconds. This is a debugging option that should only be used if instructed to by Neo4j Professional Services.



If a consistency check should be made.



Configuration file to supply additional configuration in.



Perform checks between nodes, relationships, properties, types and tokens.



Perform checks on indexes.



Perform checks on the label scan store.



Perform additional checks on property ownership. This check is very expensive in time and memory.



Directory where consistency report will be written.

7.4.2. Full backups

A full backup is performed whenever there is no backup directory specified.

Example 7.1. Back up a database

In this example, set environment variables in order to control memory usage.

The page cache is defined by using the command line option --pagecache. Further, the HEAP_SIZE environment variable will specify the maximum heap size allocated to the backup.

Now you can perform a full backup:

$neo4j-home> export HEAP_SIZE=2G
$neo4j-home> mkdir /mnt/backup
$neo4j-home> bin/neo4j-admin backup --from= --backup-dir=/mnt/backup --name=graph.db-backup --pagecache=4G
Doing full backup...
2017-02-01 14:09:09.510+0000 INFO  [o.n.c.s.StoreCopyClient] Copying neostore.nodestore.db.labels
2017-02-01 14:09:09.537+0000 INFO  [o.n.c.s.StoreCopyClient] Copied neostore.nodestore.db.labels 8.00 kB
2017-02-01 14:09:09.538+0000 INFO  [o.n.c.s.StoreCopyClient] Copying neostore.nodestore.db
2017-02-01 14:09:09.540+0000 INFO  [o.n.c.s.StoreCopyClient] Copied neostore.nodestore.db 16.00 kB

If you do a directory listing of /mnt/backup you will now see that you have a backup of Neo4j called graph-db.backup.

7.4.3. Incremental backups

An incremental backup is performed whenever an existing backup directory is specified, and the transaction logs are present since the last backup. The backup command will then copy any new transactions from Neo4j and apply them to the backup. The result will be an updated backup that is consistent with the current server state.

The transaction log files should be rotated and pruned based on the provided configuration. For example, setting dbms.tx_log.rotation.retention_policy=3 files will keep backup transaction logs to 3 files. You can use the --additional-config parameter to override this configuration.

Example 7.2. Perform an incremental backup

This example assumes that you have performed a full backup as per the previous example. In the same way as before, make sure to control the memory usage.

To perform an incremental backup you need to specify the location of your previous backup:

$neo4j-home> export HEAP_SIZE=2G
$neo4j-home> bin/neo4j-admin backup --from= --backup-dir=/mnt/backup --name=graph.db-backup --fallback-to-full=true --check-consistency=true --pagecache=4G
Destination is not empty, doing incremental backup...
Backup complete.

The incremental backup will fail if the existing directory does not contain a valid backup and --fallback-to-full=false. It will also fail if the required transaction logs have been removed and --fallback-to-full=false. Setting --fallback-to-full=true is a safeguard which will result in a full backup in case an incremental backup cannot be performed.

It is important to note that --check-consistency is true by default. For a quicker incremental backup we can set this to --check-consistency=false and --fallback-to-full=false.

When copying outstanding transactions, the server needs access to the transaction logs.

These logs are maintained by Neo4j and are automatically removed after a period of time, based on the parameter dbms.tx_log.rotation.retention_policy.

When designing your backup strategy it is important to configure dbms.tx_log.rotation.retention_policy such that transaction logs are kept between incremental backups.

7.4.4. Exit codes

neo4j-admin backup will exit with different codes depending on success or error. In the case of error, this includes details of what error was encountered.

Table 7.4. Neo4j Admin backup exit codes
Code Description




Backup failed.


Backup succeeded but consistency check failed.


Backup succeeded but consistency check found inconsistencies.