6.2. Perform a backup

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

Neo4j supports both full and incremental backups. The backup procedure is the same for a stand-alone database, for a Highly Available cluster, and for a Causal Cluster.

6.2.1. Enable backups

Backups are performed locally from a running Neo4j server, either on the database server, or over the network. The resulting files are either created locally, or on a network mounted directory located on the server performing the backup.

Two parameters must be configured in order to perform backups:

Parameter name Default value Description



Enable support for running online backups.


Listening server for online backups.

6.2.2. 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>] [--fallback-to-full[=<true|false>]]


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.



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. This argument is deprecated.



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.

Example 6.1. Back up a database

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

We define the page cache 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.

6.2.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.

Example 6.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, we 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.

6.2.4. Exit codes

neo4j-admin backup will exit with different codes depending on success or error, and in case of error, what error was encountered.

Table 6.1. Neo4j Admin backup exit codes
Code Description




Backup failed.


Backup succeeded but consistency check failed.


Backup succeeded but consistency check found inconsistencies.