Recreating sharded property databases

You can use the dbms.recreateDatabase() procedure to recreate a sharded property database in Neo4j.

It allows you to:

  • Change the database store to a specified backup, while keeping all the associated privileges for the database.

  • Make your database write-available again after it has been lost (for example, due to a disaster). See Disaster recovery for more information.

  • Delete the data and schema for a database, while keeping the database privileges assigned to each role.

  • The recreate procedure must target the virtual sharded property database.

  • Altering the store format of a sharded property database is not supported.

Remember that the recreate procedure results in downtime while the stores get updated. The time is unbounded and may depend on different factors — for example, the size of the store, network speed, etc.

For general usage, prerequisites, and seeding options, see Recreate a database.

This page describes options and considerations specific to sharded property databases.

Syntax and options

The syntax of the dbms.recreateDatabase() procedure is the same as the syntax of the dbms.recreateDatabase() procedure for standard databases, with some additional options for sharded property databases.

It takes two arguments: the database name and a map of options.

General syntax
dbms.recreateDatabase(database :: STRING, options = {} :: MAP)
Table 1. Sharded property database topology options
Option Description

seedingServers

A list of possible seeding servers. You can define available servers or provide an empty list. For details, see Use available servers as a seed.

seedURI

External source specified by URI.

clearData

Allows you to delete the data and schema for a database, while keeping the database privileges assigned to each role.

graphShardPrimaries

Number of primary allocations for the recreated sharded property database. If you set number of primaries without secondaries, then secondaries is set to 0.

graphShardSecondaries

Number of secondary allocations for the recreated sharded property database. You cannot set secondaries without primaries.

propertyShardReplicas

Number of copies for each property shard in the recreated sharded property database.

When using seedURI, the URI must point to a folder containing valid backup artifacts for all shards — the graph shard and all property shards. The backup artifacts are produced using neo4j-admin database backup or neo4j-admin database copy --target-format=backup. For details on backing up a sharded property database, see Admin operations → Backup and restore.

The seedURI option also supports:

  • A map of shard names to URIs, for example, {seedURI: {"foo-g000": "s3://bucket/foo-g000.backup", "foo-p000": "s3://bucket/foo-p000.backup"}}.

  • A list of server URIs, for example, {seedURI: ["server://server0/seeds/", "server://server1/seeds/"]}. See ServerSeedProvider for details.

Examples

Recreate from available servers

To recreate the database and let Neo4j automatically select the most up-to-date available shard stores, provide an empty seedingServers list. Before running this command, cordon any unavailable servers. For details, see Use available servers as a seed → Undefined servers.

CALL dbms.recreateDatabase("foo", {seedingServers: []});

Recreate from a backup URI

To replace all shard stores from a backup, use the seedURI option pointing to a folder containing valid backup artifacts for all shards.

CALL dbms.recreateDatabase("foo", {seedURI: "s3://my-bucket/backups/foo/"});

Recreate with a changed topology

During disaster recovery, fewer servers may be available than the original topology requires. You can change the topology of the recreated database by combining seeding options with the topology options. For details, see Change the topology.

Keep in mind that the number of property shards cannot be changed using the recreate procedure. See Resharding and consolidating databases for available methods for resharding a database, depending on your specific requirements and constraints.

CALL dbms.recreateDatabase("foo", {seedingServers: [], graphShardPrimaries: 2, graphShardSecondaries: 1, propertyShardReplicas: 3});

Clear data and schema

To delete the data (e.g., nodes and relationships) and the schema (e.g., constraints and indexes) while keeping database privileges, use the clearData option. For details, see Clear data option.

CALL dbms.recreateDatabase("foo", {clearData: true});

Using the clear data option means the data and schema will be deleted permanently. If you want to have the option of getting them back later, make sure to take a backup before clearing the database. See Admin operations → Backup and restore for details.