10.1. Backup

10.1.1. Embedded and Server
10.1.2. High Availability
10.1.3. Restoring Your Data
[Note]Note

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

Backups are performed over the network live from a running graph database onto a local copy. There are two types of backup: full and incremental.

A full backup copies the database files without acquiring any locks, allowing for continued operations on the target instance. This of course means that while copying, transactions will continue and the store will change. For this reason, the transaction that was running when the backup operation started is noted and, when the copy operation completes, all transactions from the latter down to the one happening at the end of the copy are replayed on the backup files. This ensures that the backed up data represent a consistent and up-to-date snapshot of the database storage.

In contrast, incremental backup does not copy store files - instead it copies the logs of the transactions that have taken place since the last full or incremental backup which are then replayed over an existing backup store. This makes incremental backups far more efficient that doing full backups every time but they also require that a full backup has taken place before they are executed.

Regardless of the mode a backup is created, the resulting files represent a consistent database snapshot and they can be used to boot up a Neo4j instance.

[Warning]Warning

Due to certain limitations and bugs in the JVM around file locking on some platforms performing full backups could leave a running instance to a graph database in a vulnerable state. You are therefore adviced not to perform any full backups against a running graph database until a workaround has been found. Instead of doing the initial full backup shut down the database, copy the database directory to your backup location and your database again start again. Incremental backups after that to that location are safe to perform.

The database to be backed up is specified using a URI with syntax

<running mode>://<host>[:port]{,<host>[:port]*}

Running mode must be defined and is either single for non-HA or ha for HA clusters. The <host>[:port] part points to a host running the database, on port port if not the default. The additional host:port arguments are useful for passing multiple ZooKeeper instances

[Important]Important

Backups can only be performed on databases which have the configuration parameter enable_online_backup=true set. That will make the backup service available on the default port (6362). To enable the backup service on a different port use for example enable_online_backup=port=9999 instead.

10.1.1. Embedded and Server

To perform a backup from a running embedded or server database run:

# Performing a full backup
./neo4j-backup -full -from single://192.168.1.34 -to /mnt/backup/neo4j-backup

# Performing an incremental backup
./neo4j-backup -incremental -from single://192.168.1.34 -to /mnt/backup/neo4j-backup

# Performing an incremental backup where the service is registered on a custom port
./neo4j-backup -incremental -from single://192.168.1.34:9999 -to /mnt/backup/neo4j-backup

10.1.2. High Availability

To perform a backup on an HA cluster you specify one or more ZooKeeper services managing that cluster.

# Performing a full backup from HA cluster, specifying two possible ZooKeeper services
./neo4j-backup -full -from ha://192.168.1.15:2181,192.168.1.16:2181 -to /mnt/backup/neo4j-backup

# Performing an incremental backup from HA cluster, specifying only one ZooKeeper service
./neo4j-backup -incremental -from ha://192.168.1.15:2181 -to /mnt/backup/neo4j-backup

10.1.3. Restoring Your Data

The Neo4j backups are fully functional databases. To use a backup, all you need to do replace your database folder with the backup.