Restore a database backup
Command
A database backup artifact can be restored using the restore
command of neo4j-admin
.
You must create the database (using CREATE DATABASE
against the system
database) after the restore operation finishes, unless you are replacing an existing database.
neo4j-admin database restore
must be invoked as the neo4j
user to ensure the appropriate file permissions.
For more information, see Administrative commands.
When restoring a backup chain, the transaction log contained in the differential backup artifacts need first to be replayed. This recovery operation is resource intensive and can be decoupled from the restore operation by using the aggregate command. |
Syntax
neo4j-admin database restore --from-path=<path>[,<path>...]
[--overwrite-destination=<true/false>]
[--restore-until=<recoveryCriteria>]
[--to-path-data=<path>]
[--to-path-txn=<path>]
[--verbose]
[--expand-commands]
[--force]
<database>
Options
Option | Default | Description |
---|---|---|
|
A single path or a comma-separated list of paths pointing to a backup artifact file. An artifact file can be 1) a full backup, in which case it is restored directly or, 2) a differential backup, in which case the command tries first to find in the folder a backup chain ending at that specific differential backup and then restores that chain. |
|
|
Replace an existing database. This option is not safe on a cluster since clusters have additional state that would be inconsistent with restored database. In a cluster, restore to a new database to avoid this problem. |
|
|
Differential backup artifacts contains transaction logs that can be replayed and applied to stores contained in full backup artifacts when restoring a backup chain.
The database applies logs until the recovery predicate is satisfied.
Currently supported predicates are:
|
|
|
Base directory for databases.
Usage of this option is only allowed if the |
|
|
Base directory for transaction logs.
Usage of this option is only allowed if the |
|
|
Enable verbose output. |
|
|
Allow command expansion in config value evaluation. |
|
|
Configuration file to provide additional or override the existing configuration settings in the neo4j.conf file. |
Example
The following is an example of how to perform an online restore of the database backup created in the section Back up an online database, using the neo4j-admin database restore
command.
bin/neo4j-admin database restore --from-path=/mnt/backups/neo4j-2021-11-05T11-26-38.backup --overwrite-destination neo4j
Unless you are replacing an existing database, you must create the database (using |
If you have backed up a database with the option --include-metadata
, you can manually restore the users and roles metadata.
From the <neo4j-home> directory, you run the Cypher script data/scripts/databasename/restore_metadata.cypher, which the neo4j-admin database restore
command outputs, using Cypher Shell:
Using cat
(UNIX)
cat data/scripts/databasename/restore_metadata.cypher | bin/cypher-shell -u user -p password -a ip_address:port -d system --param "database => 'databasename'"
Using type
(Windows)
type data\scripts\databasename\restore_metadata.cypher | bin\cypher-shell.bat -u user -p password -a ip_address:port -d system --param "database => 'databasename'"
Was this page helpful?