Copy a database store
A user database or backup can be copied to a Neo4j instance using the copy
command of neo4j-admin
.
In Fabric deployments, |
It is important to note that
For detailed information about supported methods of upgrade and migration, see the Neo4j Upgrade and Migration Guide. |
Command
neo4j-admin copy
copies the data store of an existing offline database to a new database.
Usage
The neo4j-admin copy
command can be used to clean up database inconsistencies, compact stores, and do a direct migration from Neo4j 3.5 to any 4.x version.
It can process an optional set of filters, which you can use to remove any unwanted data before copying the database.
The command also reclaims the unused space of a database and creates a defragmented copy of that database or backup in the destination Neo4j instance.
|
For a detailed example of how to reclaim unused space, see Reclaim unused space. |
|
Syntax
neo4j-admin copy [--verbose]
[--from-database=<database>]
[--from-path=<path>]
[--from-path-tx=<path>]
--to-database=<database>
[--neo4j-home-directory=<path>]
[--force]
[--compact-node-store]
[--to-format=<format>]
[--delete-nodes-with-labels=<label>[,<label>...]]
[--keep-only-node-properties=<label.property>[,<label.property>...]]
[--keep-only-nodes-with-labels=<label>[,<label>...]]
[--keep-only-relationship-properties=<relationship.property>[,<relationship.property>...]]
[--skip-labels=<label>[,<label>...]]
[--skip-node-properties=<label.property>[,<label.property>...]]
[--skip-properties=<property>[,<property>...]]
[--skip-relationship-properties=<relationship.property>[,<relationship.property>...]]
[--skip-relationships=<relationship>[,<relationship>...]]
[--from-pagecache=<size>]
[--to-pagecache=<size>]
Options
Option | Description |
---|---|
|
Enable verbose output. |
|
The database name to copy from. |
|
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. Use if the command cannot determine where they are located. |
|
The destination database name. |
|
Path to the home directory for the copied database. Default: The same as the database copied from. |
|
Force the command to proceed even if the integrity of the database can not be verified. |
|
Enforce node store compaction. By default, the node store is not compacted on copy since it changes the node IDs. |
|
Set the format for the new database. Valid values are Default: The format of the source database. |
|
A comma-separated list of labels. All nodes that have ANY of the specified labels will be deleted. Any node matching any of the labels will be ignored during copy. |
|
A list of property keys to keep for nodes with the specified label. Any labels not explicitly mentioned will keep their properties.
Cannot be combined with |
|
A list of labels. All nodes that have any of the specified labels will be kept.
Cannot be combined with |
|
A list of property keys to keep for relationships with the specified type. Any relationship types not explicitly mentioned will keep their properties. Cannot be combined with |
|
A comma-separated list of labels to ignore during the copy. |
|
A list of property keys to ignore for nodes with the specified label. Cannot be combined with |
|
A comma-separated list of property keys to ignore during the copy. Cannot be combined with |
|
A comma-separated list of relationship types to ignore during the copy. |
|
A list of property keys to ignore for relationships with the specified type. Cannot be combined with |
|
The size of the page cache to use for reading. |
|
The size of the page cache to use for writing. |
You can use the |
Examples
neo4j-admin copy
to copy the data store of the database neo4j
.-
Stop the database named
neo4j
:STOP DATABASE neo4j
-
Copy the data store from
neo4j
to a new database calledmy-database
:bin/neo4j-admin copy --from-database=neo4j --to-database=my-database
-
Run the following command to verify that the database has been successfully copied.
ls -al ../data/databases
Copying a database does not automatically create it. Therefore, it will not be visible if you do SHOW DATABASES
at this point. -
Create the copied database.
CREATE DATABASE my-database
-
Verify that the copied database is online.
SHOW DATABASES
-
If your original database has a schema defined, change your active database to the copied database and recreate the schema using the
neo4j-admin copy
output.The console output is saved to logs/neo4j-admin-copy-<timestamp>.log.
neo4j-admin copy
to filter the data you want to copy.The command can perform some basic forms of processing. You can filter the data that you want to copy by removing nodes, labels, properties, and relationships.
bin/neo4j-admin copy --from-database=neo4j --to-database=my-database --delete-nodes-with-labels="Cat,Dog"
The command creates a copy of the database neo4j
but without the nodes with the labels :Cat
and :Dog
.
Labels are processed independently, i.e., the filter deletes any node with a label :Cat , :Dog , or both.
|
For a detailed example of how to use |
MB/s = (IOPS * B) ÷ 10^6
, where B
is the block size in bytes; in the case of Neo4j, this is 8000
. GB/hour can then be calculated from (MB/s * 3600) ÷ 1000
.