10.3. Dump and load databases

This section describes the dump and load commands of Neo4j Admin.

A Neo4j database can be dumped and loaded using the dump and load commands of neo4j-admin:

neo4j-admin dump --database=<database> --to=<destination-path>

neo4j-admin load --from=<archive-path> --database=<database> [--force]

These commands can be useful for moving databases from one environment to another. They can also be used for offline backups of the database. For a discussion of online versus offline backups, see Section 6.1.1, “Online and offline backups”.

Example 10.6. Use the dump command of neo4j-admin

Dump the database called graph.db into a file called /backups/graph.db/2016-10-02.dump. The destination directory for the dump file — in this case /backups/graph.db — must exist before calling the command.

$neo4j-home> bin/neo4j-admin dump --database=graph.db --to=/backups/graph.db/2016-10-02.dump

$neo4j-home> ls /backups/graph.db

$neo4j-home> 2016-10-02.dump
Example 10.7. Use the load command of neo4j-admin

Load the backed-up database contained in the file /backups/graph.db/2016-10-02.dump into database graph.db. Since we have a database running, we first have to shut it down. When we use the --force option, any existing database gets overwritten.

$neo4j-home> bin/neo4j stop

Stopping Neo4j.. stopped

$neo4j-home> bin/neo4j-admin load --from=/backups/graph.db/2016-10-02.dump --database=graph.db --force

Expert users of Neo4j have become aware of the historical format and content of the database directory. Short cuts like copy-and-pasting that directory have been used to transfer and seed databases conveniently. However the form and content of the database directory may change over time and naive copy-and-paste of files is not guaranteed to work and may be harmful.

By contrast the neo4j-admin dump and neo4j-admin load commands are safe. They understand which files need to be exported and imported and which should not. As such they are the recommended way of transferring databases between servers. Arbitrary interventions at the filesystem level are discouraged.