Back to Redis

Recover

content/operate/rs/references/rest-api/requests/bdbs/actions/recover.md

latest4.3 KB
Original Source
MethodPathDescription
GET/v1/bdbs/{uid}/actions/recoverGet database recovery plan
POST/v1/bdbs/{uid}/actions/recoverRecover database

Get recovery plan {#get-bdbs-actions-recover}

sh
GET /v1/bdbs/{int: uid}/actions/recover

Fetches the recovery plan for a database. The recovery plan provides information about the recovery status, such as whether recovery is possible, and details on available files to use for recovery.

Required permissions

Permission nameRoles
[view_bdb_recovery_plan]({{< relref "/operate/rs/references/rest-api/permissions#view_bdb_recovery_plan" >}})admin
cluster_member
cluster_viewer
db_member
db_viewer

Request {#get-request}

Example HTTP request

sh
GET /v1/bdbs/1/actions/recover

URL parameters

FieldTypeDescription
uidintegerThe unique ID of the database.

Response {#get-response}

Returns a JSON object that represents the database's recovery plan, including recovery files and status.

Example response body

json
{
  "data_files": [
    {
      "filename": "appendonly-1.aof",
      "last_modified": 1721164863.8883622,
      "node_uid": "1",
      "shard_role": "master",
      "shard_slots": "1-2048",
      "shard_uid": "1",
      "size": 88
    },
    {
      "filename": "appendonly-2.aof",
      "last_modified": 1721164863.8883622,
      "node_uid": "2",
      "shard_role": "slave",
      "shard_slots": "2049-4096",
      "shard_uid": "2",
      "size": 88
    }
  ],
  "status": "ready"
}

Status codes {#get-status-codes}

CodeDescription
200 OKNo error.
404 Not FoundDatabase UID does not exist.

Recover database {#post-bdbs-actions-recover}

sh
POST /v1/bdbs/{int: uid}/actions/recover

Initiates [recovery for a database]({{<relref "operate/rs/databases/recover">}}) in a recoverable state where all the database's files are available after [cluster recovery]({{<relref "/operate/rs/clusters/cluster-recovery">}}).

Required permissions

Permission nameRoles
[start_bdb_recovery]({{< relref "/operate/rs/references/rest-api/permissions#start_bdb_recovery" >}})admin
cluster_member
db_member

Request {#post-request}

The request body can either be empty or include a recovery plan.

If the request body is empty, the database will be recovered automatically:

  • Databases with no persistence are recovered with no data.

  • Persistent files such as AOF or RDB will be loaded from their expected storage locations where replica or primary shards were last active.

  • If persistent files are not found where expected but can be located on other cluster nodes, they will be used.

Example HTTP request

sh
POST /v1/bdbs/1/actions/recover

Example request body

json
{
  "data_files": [
    {
      "filename": "appendonly-1.aof",
      "node_uid": "1",
      "shard_slots": "1-2048"
    },
    {
      "filename": "appendonly-2.aof",
      "node_uid": "2",
      "shard_slots": "2049-4096"
    }
  ],
  "ignore_errors": false,
  "recover_without_data": false
}

URL parameters

FieldTypeDescription
uidintegerThe unique ID of the database to recover.

Response {#post-response}

Returns a status code. Also returns a JSON object with an action_uid in the request body if successful.

Status codes {#post-status-codes}

CodeDescription
200 OKThe request is accepted and is being processed. When the database is recovered, its status will become active.
404 Not FoundAttempting to perform an action on a nonexistent database.
409 ConflictDatabase is currently busy with another action, recovery is already in progress, or is not in a recoverable state.