Updated on 2024-04-02 GMT+08:00

Restoring Data to the Original DB Instance

Description

  • This API is used to restore data to the original DB instance.
  • If a cluster DB instance have read replicas associated, backup data can only be restored to a new DB instance.

URI

  • URI format

    POST https://{Endpoint}/v3/{project_id}/instances/recovery

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/056538411200d4cd2f79c003c7606412/instances/recovery

Table 1 Request parameters

Name

Type

IN

Mandatory

Description

X-Auth-Token

string

header

Yes

User token obtained from IAM. For details, see Authentication.

X-Language

string

header

No

Language

project_id

string

path

Yes

Project ID. To obtain the project ID, see Obtaining a Project ID.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    Type

    Mandatory

    Description

    source

    Object

    Yes

    The instance from which the backup was created

    For details, see Table 3.

    target

    Object

    Yes

    The instance to which the backup is restored.

    For details, see Table 4.

    Table 3 source field data structure description

    Name

    Type

    Mandatory

    Description

    instance_id

    String

    Yes

    Instance ID, which can be obtained by calling the API described in Querying Instances and Details. If you do not have an instance, call the API described in Creating a DB Instance to create one.

    type

    String

    No

    The restoration mode. Enumerated values:

    • backup: indicates using backup files for restoration. In this mode, type is optional and backup_id is mandatory.
    • timestamp: indicates the point-in-time restoration mode. In this mode, type is mandatory and restore_time is mandatory.

    backup_id

    String

    No

    The ID of the backup to be restored. This parameter must be specified when the backup file is used for restoration.

    restore_time

    String

    No

    The point in time that data is restored in the UNIX timestamp. The unit is millisecond and the time zone is UTC.

    NOTE:

    This parameter takes effect only for replica set instances.

    Table 4 target field data structure description

    Name

    Type

    Mandatory

    Description

    instance_id

    String

    Yes

    Specifies ID of the DB instance to be restored from a backup. You can call the API for querying DB Instances to obtain the DB instance ID. If you do not have an instance, you can call the API used for creating an instance.

Example Request

  • Using a backup to restore data to the original DB instance whose ID is d8e6ca5a624745bcb546a227aa3ae1cfin02
    {
      "source": {
        "instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin02",
        "type": "backup",
        "backup_id": "2f4ddb93-b901-4b08-93d8-1d2e472f30fe"
      },
      "target": {
        "instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin02"
      }
    }
  • Restoring data to a point in time (applicable to replica set instances and cluster instances 4.0) (The original DB instance ID is d8e6ca5a624745bcb546a227aa3ae1cfin02.)
    {
      "source": {
        "instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin02",
        "type": "timestamp",
        "restore_time": 1532001446987
      },
      "target": {
        "instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin02"
      }
    }

Responses

  • Parameter description
    Table 5 Parameter description

    Name

    Type

    Mandatory

    Description

    job_id

    String

    Yes

    ID of the asynchronous task for the restore operation.

  • Response example
    {
        "job_id": "a03b1b8a-b756-467c-8a49-38720c3d23ec"
    }

SDK

Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.