Chapter 4. Backup

Table of Contents

This chapter covers how to perform and restore backups of a Neo4j database.

The backup features are only available in the Neo4j Enterprise Edition.

4.1. Introducing backups

Backups are performed over the network, from a running Neo4j server and into a local copy of the database store (the backup). The backup is run using the neo4j-backup tool, which is provided alongside Neo4j Enterprise Edition.

Neo4j Server must be configured to run a backup service. This is enabled via the configuration parameter dbms.backup.enabled, and is enabled by default. The interface and port the backup service listens on is configured via the parameter dbms.backup.address and defaults to the loopback interface and port 6362. It is typical to reconfigure this to listen on an external interface, by setting dbms.backup.address=<my-host-ip-address>:6362. It can also be configured to listen on all interfaces by setting dbms.backup.address=0.0.0.0:6362.

Performing a backup requires specifying the target host, an optional port, and the backup location. The backup tool will automatically select a full or incremental backup, based on whether an existing backup is present at that location.

See the configuration reference section for detailed documentation on available configuration options.

4.2. Perform a backup

4.2.1. Backup commands

# Performing a full backup: create a blank directory and run the backup tool
mkdir /mnt/backup/neo4j-backup
./bin/neo4j-backup -host 192.168.1.34 -to /mnt/backup/neo4j-backup

# Performing an incremental backup: just specify the location of your previous backup
./bin/neo4j-backup -host 192.168.1.34 -to /mnt/backup/neo4j-backup

# Performing an incremental backup where the service is listening on a non-default port
./bin/neo4j-backup -host 192.168.1.34 -port 9999 -to /mnt/backup/neo4j-backup

4.2.2. Incremental backups

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

However, the incremental backup may fail for a number of reasons:

  • If the existing directory doesn’t contain a valid backup.
  • If the existing directory contains a backup of a different database store.
  • If the existing directory contains a backup from a previous database version.

Note that when copying the outstanding transactions, the server needs access to the transaction logs. These logs are kept by Neo4j and automatically removed after a period of time, based on the parameter Table A.68, “dbms.tx_log.rotation.retention_policy”. If the required transaction logs have already been removed, the backup tool will do a full backup instead.

4.3. Restore a backup

The Neo4j backups are fully functional databases. To use a backup, simply shut down the database and replace all the files in the data directory with the backup. Then start the database.

To restore from backup in a clustered environment, follow these steps:

  1. Shut down all database instances in the cluster.
  2. Restore the backup to the individual database folders.
  3. Start the database instances.