15.9. Copy a database

This chapter describes the copy command of Neo4j Admin.

The copy command of neo4j-admin is used to copy data from an existing database to a new database.

The syntax follows:

neo4j-admin copy --to-database=<database>
                (--from-database=<database> | --from-path=<path>)

The existing database must be stopped before copying from it, and the destination database must not yet exist.

The copy command can process an optional set of filters. This can be used to remove data that is unwanted in the destination database.

The schema definitions, i.e. index and constraint, are not automatically transferred. However, they will be extracted and presented as Cypher statements so you can recreate the ones you want.


Option Description


The database name to copy from. Will assume the database is in the configured location.


The size of the page cache to use for reading.


The path to the database to copy from. It can be used to target databases outside of the installation, e.g. backups.


The path to the transaction log files. You only need to use this if the command is unable to determine where they are located.


The destination database name.


The store format of the destination database. Valid values are same, standard, high_limit. The default value for this option is the format of the source database.


The size of the page cache to use for writing.


A list of labels. Any node matching any of the labels will be ignored during copy.


A list of property keys to ignore during the copy.


A list of labels to ignore during the copy.


A list of relationship types to ignore during the copy.


Will instruct the tool to print more verbose output.


Will force the command to proceed even if the integrity of the database can not be verified.

Due to the way filters are processed, the id of the node might change. This is true even if no filters are specified.


Example 15.16. Use the copy command to take a copy of the database neo4j.

To begin, you must stop the database named neo4j; this can be done by issuing the following Cypher statement:


You can now copy the data from neo4j, to a new database called copy:

$neo4j-home> bin/neo4j-admin copy --from-database=neo4j --to-database=copy

A new database with the name copy now exists on the server, but it is not automatically picked up by Neo4j. To start the new database you have to insert it into Neo4j with the following Cypher query:


Neo4j will then detect the copied database and begin to use that.

Remember to start the database you copied from, if you still want it, using:


The console output is saved to logs/neo4j-admin-copy-<date>.log.

Example 15.17. Use the copy command with filters.

The command can perform some basic forms of processing. You can remove nodes, labels, properties, and/or relationships.

The difference with --skip-labels and --delete-nodes-with-labels is that --skip-labels will just remove the labels, potentially leaving nodes without any labels.

$neo4j-home> bin/neo4j-admin copy --from-database=neo4j --to-database=copy --delete-nodes-with-labels="Cat,Dog"

After this command, you will have a copy of the database neo4j, without nodes with the labels :Cat and :Dogs.

Labels are processed independently, i.e. the filter described above will delete any node with either :Cat or :Dogs, and not only nodes that have both of the labels.