You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/backup-restore/copy-database.adoc
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
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.
8
8
`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.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/backup-restore/restore-backup.adoc
+18-7Lines changed: 18 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,10 +172,10 @@ The `LOWEST TX` and `HIGHEST TX` columns show the transaction IDs of the first a
172
172
That means, if you restore `neo4j-2023-06-29T14-50-45.backup`, your database will have `14` as the last transaction ID.
173
173
174
174
175
-
=== Restore a database backup
175
+
=== Restore a database backup in a standalone environment
176
176
177
177
The following examples assume that you want to restore your data in a new database, called `mydatabase`.
178
-
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.
178
+
If you want to replace an existing standalone database, you need to stop it first and add the option `--overwrite-destination=true` to the restore command.
179
179
180
180
. Restore a database backup by running the following command:
181
181
+
@@ -235,6 +235,7 @@ For example, `--restore-until=123`.
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].
299
+
To restore a database backup in a cluster, you can use one of the following methods:
300
+
301
+
* Designate one of the servers to be used as a seeder, and restore the database backup on that server.
302
+
For more information, see xref:clustering/databases.adoc#cluster-designated-seeder[Restore a database using a server as a designated seeder].
303
+
* Recreate a database from a backup or server URI.
304
+
See xref:clustering/databases.adoc#restore-database-using-uri-approach[Restore a database using URI approach] for more information.
305
+
* Recreate a database using the `dbms.recreateDatabase()` procedure.
306
+
See xref:clustering/databases.adoc#restore-database-using-recreate-procedure[Restore a database using `dbms.recreateDatabase()`] for more details.
307
+
* label:new[Introduced in 2026.03] Use the xref:backup-restore/copy-database.adoc[`neo4j-admin database copy`] command.
308
+
See xref:clustering/databases.adoc#restore-database-using-copy-command[Restore a database backup using the `neo4j-admin database copy` command] for more details.
309
+
300
310
301
311
=== Restore users and roles metadata
302
312
303
-
If you have backed up a database with the option `--include-metadata`, you can manually restore the users, roles, and auth rules metadata.
313
+
Roles and users metadata are backed up during the backup process by default.
304
314
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[]:
315
+
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[]:
306
316
307
317
*Using `cat` (UNIX)*
308
318
[source, shell, role=nocopy noplay]
@@ -315,3 +325,4 @@ cat ../data/scripts/databasename/restore_metadata.cypher | bin/cypher-shell -u u
315
325
----
316
326
type ..\data\scripts\databasename\restore_metadata.cypher | bin\cypher-shell.bat -u user -p password -a ip_address:port -d system --param "database => 'databasename'"
Copy file name to clipboardExpand all lines: modules/ROOT/pages/backup-restore/restore-dump.adoc
+16-8Lines changed: 16 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,15 +108,8 @@ The `--overwrite-destination` option is required because you are replacing the e
108
108
109
109
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.
110
110
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
-
====
118
111
119
-
[NOTE]
112
+
[IMPORTANT]
120
113
====
121
114
`neo4j-admin database load` cannot be applied to xref:scalability/composite-databases/concepts.adoc[Composite databases].
122
115
It must be run directly on the databases that are associated with that Composite database.
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.
202
+
203
+
Alternatively, you can stop the Neo4j server and unbind it from the cluster using xref:clustering/unbind.adoc[`neo4j-admin server unbind`] to remove its cluster state data.
204
+
205
+
If you fail to `DROP` the database or unbind a server before loading the dump, 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
+
208
+
It is recommended to restore a database dump using a URI approach.
209
+
See xref:database-administration/standard-databases/seed-from-uri.adoc[] for details.
== Restore a clustered database from a `.backup`/`.dump`
279
279
280
-
There are two different ways to seed a cluster with data:
280
+
To restore a clustered database from a backup, or to seed a cluster with data:
281
281
282
-
* The first option is to use a _designated seeder_, where a designated server is used to create a backed-up database on other servers in the cluster.
283
-
* The other option is to seed the cluster from a URI, where all servers to host the database are seeded with an identical seed from an external source specified by that URI.
282
+
* You can use a _designated seeder_, where a designated server is used to create a backed-up database on other servers in the cluster.
283
+
* You can seed the cluster from a URI, where all servers to host the database are seeded with an identical seed from an external source specified by that URI.
284
284
For more details, see xref:database-administration/standard-databases/seed-from-uri.adoc[Create a database from a URI].
285
+
* You can use the `dbms.recreateDatabase()` procedure.
286
+
* You can also use the `neo4j-admin database copy` command.
285
287
288
+
[NOTE]
289
+
====
286
290
Keep in mind that using a designated seeder can be problematic in some situations as it is not known in advance how a database is going to be allocated to the servers in a cluster.
287
291
Also, this method relies on the seed already existing on one of the servers.
292
+
====
288
293
289
294
290
295
[[cluster-designated-seeder]]
291
-
=== Designated seeder
296
+
=== Restore a database using a designated seeder
292
297
293
-
In order to designate a server in the cluster as a seeder, a database backup is transferred to that server using the xref:backup-restore/restore-backup.adoc[`neo4j-admin database restore`] command.
298
+
In order to designate a server in the cluster as _a seeder_, a database backup is transferred to that server using the xref:backup-restore/restore-backup.adoc[`neo4j-admin database restore`] command.
294
299
Subsequently, that server is used as the source for other cluster members to copy the backed-up database from.
295
300
296
301
This example creates a user database called `foo`, hosted on three servers in primary mode.
@@ -332,7 +337,7 @@ This may be different from the topology of `foo` when it was backed up.
332
337
If you want to ensure a certain allocation across the cluster, you can specify the desired topology with the `TOPOLOGY` clause in the `CREATE DATABASE` command.
333
338
See <<create-database, `CREATE DATABASE`>> for more information.
334
339
+
335
-
[source, cypher, role=noplay]
340
+
[source, cypher5, role=noplay]
336
341
----
337
342
CREATE DATABASE foo
338
343
TOPOLOGY [desired number of primaries] PRIMARIES [desired number of secondaries] SECONDARIES
@@ -359,6 +364,193 @@ SHOW DATABASE foo;
359
364
9 rows available after 3 ms, consumed after another 1 ms
360
365
----
361
366
367
+
368
+
[[restore-database-using-uri-approach]]
369
+
=== Restore a database from a URI
370
+
371
+
Before restoring a database, you have to take its backup and drop the database on all servers.
372
+
If you have not dropped the database before restoring it, use `CREATE OR REPLACE DATABASE` instead of the `CREATE DATABASE` command.
373
+
374
+
The seed can be a full backup, a differential backup, or a dump from an existing database.
375
+
When using `CloudSeedProvider`, the URI can point also to a folder which contains a backup chain.
376
+
The sources of seeds are called _seed providers_. +
377
+
For detailed information about seed providers in Neo4j, see xref:database-administration/standard-databases/seed-from-uri.adoc[].
378
+
379
+
Remember that the dump file created with the xref:backup-restore/offline-backup.adoc#offline-backup-command[`neo4j-admin database dump`] command contains only the database data.
380
+
The associated users and roles metadata are not included and must be recreated manually after restore.
381
+
382
+
When restoring a database from a backup seed in a cluster, you have to define the database topology.
383
+
You have the opportunity to create a topology that will differ from an original one.
384
+
385
+
The new allocations can be put on any available server in the cluster.
386
+
387
+
On one of the servers, run the command:
388
+
389
+
[.tabbed-example]
390
+
=====
391
+
[role=include-with-Cypher-25 label--new-2025.06]
392
+
======
393
+
394
+
[source, cypher25]
395
+
----
396
+
CREATE DATABASE foo
397
+
TOPOLOGY [desired number of primaries] PRIMARIES [desired number of secondaries] SECONDARIES
Number of primaries and secondaries must respect the number of available servers and their mode constraints.
415
+
The `CREATE DATABASE` command automatically allocates the database.
416
+
417
+
If you restore your database from a backup file created with the xref:backup-restore/online-backup.adoc[`neo4j-admin database backup`] command, users and roles metadata is backed up by default unless you have changed the default value of the `--include-metadata` option.
418
+
As a final step, you can xref:backup-restore/restore-backup.adoc#_restore_users_and_roles_metadata[restore users and roles metadata].
419
+
This step is optional.
420
+
421
+
Verify that the restored database is online on the desired number of servers, in the desired roles by running the `SHOW DATABASES` command.
422
+
423
+
Starting with 2026.04, you can also restore a database from a server URI using the `server://` scheme.
424
+
See xref:database-administration/standard-databases/seed-from-uri.adoc#server-seed-provider[Create a database from a URI -> `ServerSeedProvider`] for details.
425
+
426
+
427
+
[[restore-database-using-recreate-procedure]]
428
+
=== Restore a database using the `dbms.recreateDatabase()` procedure
429
+
430
+
For detailed information on the recreate procedure, its options and limitations, see xref:database-administration/standard-databases/recreate-database.adoc[].
431
+
432
+
You need xref:authentication-authorization/dbms-administration/dbms-database-management-privileges.adoc[the `CREATE DATABASE` and `DROP DATABASE` privileges] to run the recreate procedure.
433
+
434
+
If you provide a URI to a backup or a dump, the stores on all servers will be replaced by the backup or the dump at the given URI.
435
+
The new database allocations can be put on any `ENABLED` server in the cluster.
436
+
437
+
To restore a database using backup as a seed and keeping the original database topology, run the command:
If a database is restored using `dbms.recreateDatabase()`, all previously granted user and role privileges on that database are preserved.
452
+
453
+
Verify that the restored database is online on the desired number of servers, in the desired roles by running the `SHOW DATABASES` command.
454
+
455
+
456
+
[role=label--new-2026.03]
457
+
[[restore-database-using-copy-command]]
458
+
=== Restore a database backup using the `neo4j-admin database copy` command
459
+
460
+
See xref:backup-restore/copy-database.adoc#neo4j-admin-copy-command-limitations[Command limitations] before using this option.
461
+
462
+
The following example assumes that you have a backup of your existing database `foo` in an AWS S3 bucket.
463
+
Before restoring a database, you do not need to stop or drop the database `foo`.
464
+
465
+
The following options can be specified for the `neo4j-admin database copy` command:
466
+
467
+
* `--source-location` -- a path to the full backup of an existing database or the last differential backup in the chain.
468
+
This folder can be located locally or remotely (e.g., an S3 bucket) and must contain the full backup and all the differential backups in the chain, if any.
469
+
* `--source-format=backup` -- the format of the source backup.
470
+
* `--copy-schema` -- (optional) to copy the schema of the existing database if needed.
471
+
* `--target-location` -- a path to a folder for target backup artifact data. Used together with `--target-format=backup`.
472
+
* `--target-format` -- the format of the output data.
473
+
Possible values are `backup` and `database` (default).
See xref:backup-restore/copy-database.adoc#copy-database-command-options[Copy a database store] for more information.
476
+
477
+
`--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.
478
+
479
+
. Copy the data from a backup of your standard database `foo` into the database `foo-restored`.
Number of primaries and secondaries must respect the number of available servers and their mode constraints.
517
+
518
+
. Wait until the last committed transaction ID is the same for all allocations of the database and then verify that the new database is online by running the following command:
519
+
+
520
+
[source, cypher]
521
+
----
522
+
SHOW DATABASES;
523
+
----
524
+
. After the new database is online, you can drop the old database `foo` if it is no longer needed, or put it into read-write mode if you want to keep it for other purposes.
525
+
+
526
+
[.tabbed-example]
527
+
=====
528
+
[.include-with-drop-database]
529
+
======
530
+
531
+
Run the following command to drop the old database `foo`:
532
+
533
+
[source, cypher]
534
+
----
535
+
DROP DATABASE foo;
536
+
----
537
+
======
538
+
[.include-with-change-access-mode]
539
+
======
540
+
541
+
Change the access mode of the old database `foo` to read-write:
542
+
543
+
[source, cypher]
544
+
----
545
+
ALTER DATABASE foo SET ACCESS READ WRITE;
546
+
----
547
+
======
548
+
=====
549
+
550
+
551
+
552
+
553
+
362
554
[[cluster-allow-deny-db]]
363
555
== Controlling locations with allowed/denied databases
364
556
@@ -374,6 +566,7 @@ Note that starting from 2025.12, database name patterns (wildcards) are supporte
374
566
** `modeConstraint` - controls in what mode (primary, secondary, or none) databases can be hosted on a server.
375
567
If not set, there are no mode constraints on the server.
0 commit comments