Restoring database causes 2 servers and 2 system dbs errors

I'm using Neo4j V5.26.5 (LTS) on AWS EC2, enterprise edition.

I'm testing the backup and restore on my single EC2 Neo4j instance and I'm getting a corrupt system when I restore a single database.

From a fresh install of Neo4j on an EC2 I backed up the (empty) Neo4j database, then tried to restore it to a different install of Neo4j on a different EC2. Both are stand alone, no clustering.

Before I do the restore the system looks like this:

neo4j@neo4j> show servers;
+-------------------------------------------------------------------------------------------------------------+
| name                                   | address            | state     | health      | hosting             |
+-------------------------------------------------------------------------------------------------------------+
| "b93af5f7-648f-46ea-9812-b8430775159e" | "10.0.157.20:7475" | "Enabled" | "Available" | ["neo4j", "system"] |
+-------------------------------------------------------------------------------------------------------------+
neo4j@neo4j> show databases;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name     | type       | aliases | access       | address            | role      | writer | requestedStatus | currentStatus | statusMessage | default | home  | constituents |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "neo4j"  | "standard" | []      | "read-write" | "10.0.157.20:7475" | "primary" | TRUE   | "online"        | "online"      | ""            | TRUE    | TRUE  | []           |
| "system" | "system"   | []      | "read-write" | "10.0.157.20:7475" | "primary" | TRUE   | "online"        | "online"      | ""            | FALSE   | FALSE | []           |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Then I perform the restore using:

sudo systemctl stop neo4j
sudo -g neo4j -u neo4j neo4j-admin database restore --overwrite-destination=true --from-path=s3://mybucket/mydir/neo4j.backup neo4j
sudo systemctl start neo4j

After the restore my Neo4j database is unavailable and my system looks like this:

neo4j@system> show servers;
+------------------------------------------------------------------------------------------------------+
| name                                   | address            | state     | health        | hosting    |
+------------------------------------------------------------------------------------------------------+
| "36dcd366-60f0-4f40-ba0d-5d442e31263f" | "10.0.157.20:7475" | "Free"    | "Available"   | ["system"] |
| "b93af5f7-648f-46ea-9812-b8430775159e" | NULL               | "Enabled" | "Unavailable" | []         |
+------------------------------------------------------------------------------------------------------+
neo4j@system> show databases;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name     | type       | aliases | access       | address            | role      | writer | requestedStatus | currentStatus | statusMessage           | default | home  | constituents |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "neo4j"  | "standard" | []      | "read-only"  | NULL               | "primary" | FALSE  | "online"        | "unknown"     | "Server is unavailable" | TRUE    | TRUE  | []           |
| "system" | "system"   | []      | "read-write" | NULL               | NULL      | FALSE  | "online"        | "unknown"     | "Server is unavailable" | FALSE   | FALSE | []           |
| "system" | "system"   | []      | "read-write" | "10.0.157.20:7475" | "primary" | TRUE   | "online"        | "online"      | ""                      | FALSE   | FALSE | []           |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

These are non-clustered stand alone instances of Neo4j enterprise. This should be a very simple operation however why am I getting these results. The system is unusable after performing the restore.

There are no errors or exceptions in the neo4j.log or debug.log.

Interestingly in the Neo4j.log file it looks like the ServerId has changed:
Before the restore operation:

INFO  Starting...
INFO  ======== Neo4j 5.26.5 ========
INFO  This instance is ServerId{b93af5f7} (b93af5f7-648f-46ea-9812-b8430775159e)
INFO  Default database 'neo4j' is created
INFO  Anonymous Usage Data is being sent to Neo4j, see https://neo4j.com/docs/usage-data/
INFO  Sending metrics to CSV file at /var/lib/neo4j/metrics
...
INFO  id: 9CBF288C51A0C1A8BCEA571631B7ACE6E5076D263E19AFD510E46AE3E1A6AB07
INFO  name: system
INFO  creationDate: 2025-04-23T10:53:27.257Z
INFO  Started.

and after the restore operation:

INFO  Starting...
INFO  ======== Neo4j 5.26.5 ========
INFO  This instance is ServerId{36dcd366} (36dcd366-60f0-4f40-ba0d-5d442e31263f)
INFO  Anonymous Usage Data is being sent to Neo4j, see https://neo4j.com/docs/usage-data/
INFO  Sending metrics to CSV file at /var/lib/neo4j/metrics
...
INFO  id: 9CBF288C51A0C1A8BCEA571631B7ACE6E5076D263E19AFD510E46AE3E1A6AB07
INFO  name: system
INFO  creationDate: 2025-04-23T10:53:27.257Z
INFO  Started.

Note how the server id has changed. Is this normal?

I finally found a solution for this.

If you want to restore a stand-alone Neo4j server including things like roles which are stored in the system database, then you need to restore the system database. If you just restore the system database you end up with two system databases as above. To stop this happening you need to copy the system_id file from the /var/lib/neo4j/data directory from the original server to the new server. When copying the file make sure it has the correct permissions, namely owner and group of 'neo4j'. Once you have done this you can restore the system database (and probably any other databases you require). You will need to stop the service (sudo systemctl stop neo4j) before you copy the system_id file and restore the system database.

Interestingly the documentation talks about how important it is to backup the system database but it doesn't talk about how to restore it and there's no mention of the server_id file at all.

I was wondering if there is a way to set the server id without copying files. An admin operation or something. I couldn't find anything.