This chapter covers how to perform and restore backups of a Neo4j database.
The backup features are only available in the Neo4j Enterprise Edition.
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
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.
# 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
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:
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.
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: