Skip to content

Commit f676351

Browse files
Clarify how to restore a database backup in cluster (#3035)
Our restore documentation is very standalone minded. This PR attempts to cover methods on how to restore a clustered database from a backup or dump file.
1 parent 7ed9880 commit f676351

5 files changed

Lines changed: 365 additions & 32 deletions

File tree

modules/ROOT/pages/backup-restore/copy-database.adoc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
You can use the `neo4j-admin database copy` command to copy a database, create a compacted/defragmented copy of a database, clean up database inconsistencies, or do a direct migration from Neo4j 4.4 to any 5.x version.
88
`neo4j-admin database copy` reclaims the unused space, creates a defragmented copy of the _data store_, and creates the node label and relationship type lookup indexes.
99

10+
[[neo4j-admin-copy-command-limitations]]
1011
.Command limitations
1112
[NOTE]
1213
====
@@ -384,6 +385,78 @@ START DATABASE neo4j
384385
For a detailed example of how to reclaim unused space, see xref:performance/space-reuse.adoc#space-reuse-reclaim-space[Reclaim unused space].
385386
====
386387

388+
[role=label--new-2026.03]
389+
[[copy-data-store-from-backup]]
390+
=== Copy the data store from a backup
391+
392+
The following example assumes that you have a backup (created with the `neo4j-admin database backup` command) of your existing database `foo` in an AWS S3 bucket.
393+
394+
Before copying the database store from a backup, you do not need to stop or drop the database `foo`.
395+
396+
You can specify any differential backup in the chain.
397+
Then the entire chain up to that point must be located in the same folder as the specified diff.
398+
The chain will be found in the folder and all changes in that chain up to the point specified will be part of the result database from the copy operation.
399+
If not, the command will fail due to incomplete chain.
400+
401+
[IMPORTANT]
402+
====
403+
`--source-location` and `--source-format` cannot be used together with `--from-path-data` and/or `--from-path-txn` due to the conflict in trying to supply data from two different locations at once.
404+
405+
The copy command does not copy over users and roles metadata.
406+
You have to copy and re-apply them manually.
407+
====
408+
409+
. Copy the data from a backup of your standard database `foo` into a backup for the database `foo-restored`.
410+
+
411+
[source, shell]
412+
----
413+
neo4j-admin database copy foo foo-restored --source-location=s3://bucket/folder/foo.backup --source-format=backup --copy-schema --target-location=s3://bucket/folder --target-format=backup
414+
----
415+
+
416+
Copying a database does not automatically create it.
417+
Therefore, it will not be visible if you do `SHOW DATABASES` at this point.
418+
419+
. Run the following command to create the database `foo-restored` by seeding it from your backup folder in the AWS S3 bucket:
420+
+
421+
[.tabbed-example]
422+
=====
423+
[role=include-with-Cypher-25 label--new-2025.06]
424+
======
425+
426+
[source, cypher]
427+
----
428+
CREATE DATABASE foo-restored
429+
OPTIONS {seedUri: “s3://bucket/folder/”};
430+
----
431+
432+
======
433+
[role=include-with-Cypher-5]
434+
======
435+
436+
[source, cypher]
437+
----
438+
CREATE DATABASE foo-restored
439+
OPTIONS {existingData: 'use', seedUri: “s3://bucket/folder/”};
440+
----
441+
======
442+
=====
443+
444+
. Verify that the new database is online by running the following command:
445+
+
446+
[source, cypher]
447+
----
448+
SHOW DATABASES;
449+
----
450+
. After the new database is online, you can drop the old database `foo`.
451+
+
452+
Run the following command to drop the old database `foo`:
453+
+
454+
[source, cypher]
455+
----
456+
DROP DATABASE foo;
457+
----
458+
459+
387460
[[copy-estimating-iops]]
388461
== Estimating the processing time
389462

modules/ROOT/pages/backup-restore/online-backup.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Note that it is not allowed to take a backup of a database alias, only physical
1313
[[online-backup-command]]
1414
== Command
1515

16-
A Neo4j database can be backed up in **online mode** using the `backup` command of `neo4j-admin`.
16+
A Neo4j database can be backed up in **online mode** using the `neo4j-admin database backup` command.
1717
The command must be invoked as the `neo4j` user to ensure the appropriate file permissions.
1818

1919
It is best practice, but not mandatory, to perform the backup from a server on the same network as the database, but that is not part of the cluster.

modules/ROOT/pages/backup-restore/restore-backup.adoc

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,40 @@
33
[[restore-backup]]
44
= Restore a database backup
55

6+
Neo4j suggests a few options to restore a database backup artifact (full or differential) created with the xref:backup-restore/online-backup.adoc[`neo4j-admin database backup`] command.
7+
8+
== Restore a database on a standalone server
9+
10+
To restore a database from a backup in a standalone server environment, use one of the following methods:
11+
12+
* Use the <<restore-backup-command, `neo4j-admin database restore`>> command.
13+
* Restore a database using URI approach.
14+
See xref:database-administration/standard-databases/seed-from-uri.adoc[] for detailed information.
15+
* Recreate a database using the xref:database-administration/standard-databases/recreate-database.adoc[`dbms.recreateDatabase()` procedure].
16+
* label:new[Introduced in 2026.03] Use the xref:backup-restore/copy-database.adoc[`neo4j-admin database copy`] command to restore database data from a backup.
17+
See xref:backup-restore/copy-database.adoc#copy-data-store-from-backup[Copy database data from a backup] for an example.
18+
* You can also load a **full** database backup artifact using the xref:backup-restore/restore-dump.adoc[`neo4j-admin database load`] command.
19+
This functionality is available in the Community Edition.
20+
21+
== Restore a clustered database from a backup
22+
23+
To restore a database from a backup in a clustered environment, use one of the following methods:
24+
25+
* Recreate a database from a URI.
26+
See xref:clustering/databases.adoc#restore-database-using-uri-approach[Restore a database in cluster using URI approach] for more information.
27+
* Designate one of the servers to be used as a seeder, and restore the database backup on that server.
28+
For more information, see xref:clustering/databases.adoc#cluster-designated-seeder[Restore a database using a server as a designated seeder].
29+
* Recreate a database using the `dbms.recreateDatabase()` procedure.
30+
See xref:clustering/databases.adoc#restore-database-using-recreate-procedure[Restore a database using `dbms.recreateDatabase()`] for more details.
31+
* label:new[Introduced in 2026.03] Use the xref:backup-restore/copy-database.adoc[`neo4j-admin database copy`] command.
32+
See xref:clustering/databases.adoc#restore-database-using-copy-command[Restore a clustered database using the `copy` command] for more details.
33+
634
[[restore-backup-command]]
735
== Command
836

937
A database backup artifact (full or differential) can be restored within the same or to a later Neo4j version using the `restore` command of `neo4j-admin`.
1038

11-
You can also load a **full** database backup artifact using the xref:backup-restore/restore-dump.adoc[`neo4j-admin database load`] command.
12-
This functionality is available in the Community Edition.
13-
14-
[NOTE]
39+
[IMPORTANT]
1540
====
1641
Restoring a database backup to a previous Neo4j version is not supported.
1742
====
@@ -172,7 +197,7 @@ The `LOWEST TX` and `HIGHEST TX` columns show the transaction IDs of the first a
172197
That means, if you restore `neo4j-2023-06-29T14-50-45.backup`, your database will have `14` as the last transaction ID.
173198

174199

175-
=== Restore a database backup
200+
=== Restore a backup on a standalone server
176201

177202
The following examples assume that you want to restore your data in a new database, called `mydatabase`.
178203
If you want to replace an existing database, you need to stop it first and add the option `--overwrite-destination=true` to the restore command.
@@ -235,6 +260,7 @@ For example, `--restore-until=123`.
235260
CREATE DATABASE mydatabase;
236261
----
237262

263+
238264
[[restore-cloud-storage]]
239265
=== Restore a backup located in cloud storage
240266

@@ -261,6 +287,14 @@ The example assumes that you have backup artifacts located in the `myBucket/myDi
261287
----
262288
bin/neo4j-admin database restore --from-path=s3://myBucket/myDirectory/myBackup.backup mydatabase
263289
----
290+
291+
. If you have not stopped your database and used the `--overwrite-destination=true` option, you have to create the new `mydatabase` by running the command:
292+
+
293+
[source,cypher]
294+
----
295+
CREATE DATABASE mydatabase;
296+
----
297+
264298
======
265299
266300
[role=include-with-Google-cloud-storage]
@@ -275,6 +309,14 @@ The example assumes that you have backup artifacts located in the `myBucket/myDi
275309
----
276310
bin/neo4j-admin database restore --from-path=gs://myBucket/myDirectory/myBackup.backup mydatabase
277311
----
312+
313+
. If you have not stopped your database and used the `--overwrite-destination=true` option, you have to create the new `mydatabase` by running the command:
314+
+
315+
[source,cypher]
316+
----
317+
CREATE DATABASE mydatabase;
318+
----
319+
278320
======
279321
280322
[role=include-with-Azure-cloud-storage]
@@ -289,20 +331,23 @@ The example assumes that you have backup artifacts located in the `myStorageAcco
289331
----
290332
bin/neo4j-admin database restore --from-path=azb://myStorageAccount/myContainer/myDirectory/myBackup.backup mydatabase
291333
----
334+
335+
. If you have not stopped your database and used the `--overwrite-destination=true` option, you have to create the new `mydatabase` by running the command:
336+
+
337+
[source,cypher]
338+
----
339+
CREATE DATABASE mydatabase;
340+
----
341+
292342
======
293343
=====
294344

295-
=== Restore a database backup in a cluster
296345

297-
To restore a database backup in a cluster, designate one of the servers to be used as a seeder, and restore the database backup on that server.
298-
Then, use that server to create the restored database on other servers in the cluster.
299-
For more information, see xref:clustering/databases.adoc#cluster-seed[Designated seeder].
346+
== Restore users and roles metadata
300347

301-
=== Restore users and roles metadata
348+
Users, roles, and auth rules metadata are backed up during the backup process by default.
302349

303-
If you have backed up a database with the option `--include-metadata`, you can manually restore the users, roles, and auth rules metadata.
304-
305-
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 xref:cypher-shell.adoc[]:
350+
If you need to restore the users and roles metadata, you have to do it manually by running the Cypher script from the _<NEO4J_HOME>_ directory, _/data/scripts/databasename/restore_metadata.cypher_, which the `neo4j-admin database restore` command outputs, using xref:cypher-shell.adoc[]:
306351

307352
*Using `cat` (UNIX)*
308353
[source, shell, role=nocopy noplay]
@@ -315,3 +360,4 @@ cat ../data/scripts/databasename/restore_metadata.cypher | bin/cypher-shell -u u
315360
----
316361
type ..\data\scripts\databasename\restore_metadata.cypher | bin\cypher-shell.bat -u user -p password -a ip_address:port -d system --param "database => 'databasename'"
317362
----
363+

modules/ROOT/pages/backup-restore/restore-dump.adoc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The `neo4j-admin database load` command can be used to load a database from an archive created with the xref:backup-restore/offline-backup.adoc#offline-backup-command[`neo4j-admin database dump`] command or a full backup artifact created by the xref:backup-restore/online-backup.adoc[`neo4j-admin database backup`] command from Neo4j Enterprise.
66

7-
If you are replacing an existing database, you have to shut it down before running the command and use the `--overwrite-destination` option. +
7+
If you are replacing an existing database on a standalone server, you have to shut it down before running the command and use the `--overwrite-destination` option. +
88
label:enterprise-edition[] If you are not replacing an existing database, you must create the database (using `CREATE DATABASE` against the `system` database) after the load operation finishes.
99

1010
The command can be run from either an online or offline Neo4j DBMS on Enterprise edition.
@@ -108,15 +108,8 @@ The `--overwrite-destination` option is required because you are replacing the e
108108

109109
If you are not replacing an existing database in Enterprise Edition, you must create the database (using `CREATE DATABASE` against the `system` database) after the load operation finishes.
110110

111-
[NOTE]
112-
====
113-
When using the `load` command to seed a cluster, and a previous version of the database exists, you must delete it (using `DROP DATABASE`) first.
114-
Alternatively, you can stop the Neo4j instance and unbind it from the cluster using `neo4j-admin server unbind` to remove its cluster state data.
115-
If you fail to DROP or unbind before loading the dump, that database’s store files will be out of sync with its cluster state, potentially leading to logical corruptions.
116-
For more information, see xref:clustering/databases.adoc#cluster-seed[Seed a cluster].
117-
====
118111

119-
[NOTE]
112+
[IMPORTANT]
120113
====
121114
`neo4j-admin database load` cannot be applied to xref:scalability/composite-databases/concepts.adoc[Composite databases].
122115
It must be run directly on the databases that are associated with that Composite database.
@@ -200,3 +193,15 @@ bin/neo4j-admin database load mydatabase --from-path=azb://myStorageAccount/myCo
200193
======
201194
=====
202195

196+
197+
[role=label--enterprise-edition]
198+
[[restore-dump-in-cluster]]
199+
=== Restore a clustered database from a dump
200+
201+
It is recommended to restore a clustered database from a dump using a URI approach.
202+
See xref:database-administration/standard-databases/seed-from-uri.adoc[] for details.
203+
204+
When using the `neo4j-admin database load` command to seed a cluster, and a previous version of the database exists, you must delete it (using `DROP DATABASE`) first.
205+
If you fail to `DROP` the database, that database’s store files will be out of sync with its cluster state, potentially leading to logical corruptions.
206+
For more information, see xref:clustering/databases.adoc#cluster-designated-seeder[Restore a database using a designated seeder].
207+

0 commit comments

Comments
 (0)