Updated on 2023-11-24 GMT+08:00

Restoring Databases and Tables to a Point in Time

Description

This API is used to restore databases and tables at a point in time.

Restrictions

This API applies only to replica sets.

URI

  • URI format

    POST https://{Endpoint}/v3/{project_id}/instances/{instance_id}/restore/collections

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/056538411200d4cd2f79c003c7606412/instances/d5833c2854a4486cb7960f829269e211in02/restore/collections

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.

instance_id

string

path

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.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    Type

    Mandatory

    Description

    restore_collections

    Array of objects

    Yes

    The database information.

    For details, see Table 3.

    Table 3 restore_collections data structure description

    Name

    Type

    Mandatory

    Description

    database

    String

    Yes

    Database name.

    collections

    Array of objects

    No

    The collection information.

    For details, see Table 4.

    restore_database_time

    String

    No

    The database restoration time point.

    This parameter is mandatory for database-level restoration,

    The value is a UNIX timestamp, in milliseconds. The time zone is UTC.

    Table 4 collections data structure description

    Name

    Type

    Mandatory

    Description

    old_name

    String

    Yes

    The table name before the restoration.

    new_name

    String

    No

    The table name after the restoration.

    restore_collection_time

    String

    Yes

    The collection restoration time point.

    The value is a UNIX timestamp, in milliseconds. The time zone is UTC.

Example Request

  • Restoring a database-level backup (The database name is test.)
    {
      "restore_collections": [
        {
          "database": "test",
          "restore_database_time": 1607762955000
        }
      ]
    }
  • Restoring a collection-level backup (The table name before the restoration is test.)
    {
      "restore_collections": [
        {
          "database": "test",
          "collections": [
            {
              "old_name": "test",
              "restore_collection_time": 1607762955000
            }
          ]
        }
      ]
    }

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.