Updated on 2022-12-12 GMT+08:00

Restoring Data to a New DB Instance

Description

This API is used to restore a backup to a new DB instance.

Restrictions

  • This API supports restoring backups to both the yearly/monthly and pay-per-use DB instances.
  • The database type of the destination DB instance must be the same as that of the source DB instance.
  • Currently, only replica set instances and cluster instances 4.0 can be restored to a new instance and to any point in time.

URI

  • URI format

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

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/97b026aa9cc4417888c14c84a1ad9860/instances

Table 1 Request parameters

Name

Type

IN

Mandatory

Description

x-auth-token

string

header

Yes

User token

project_id

string

path

Yes

Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    Type

    Mandatory

    Description

    name

    String

    Yes

    The DB instance name.

    The instance name can be the same as an existing name.

    The instance name must contain 4 to 64 characters and must start with a letter. It is case sensitive and can contain letters, digits, hyphens (-), and underscores (_). It cannot contain other special characters.

    availability_zone

    String

    Yes

    AZ ID.

    vpc_id

    String

    Yes

    VPC ID.

    For details about how to obtain this parameter value, see "Virtual Private Cloud" in the Virtual Private Cloud API Reference.

    The value cannot be empty. The string length and whether the string complying with UUID regular expression rules are verified.

    subnet_id

    String

    Yes

    Subnet ID.

    For details about how to obtain this parameter value, see "Subnet" in the Virtual Private Cloud API Reference.

    security_group_id

    String

    Yes

    Specifies the ID of the security group where a specified DB instance belongs to.

    For details about how to obtain this parameter value, see "Security Group" in the Virtual Private Cloud API Reference.

    password

    String

    No

    Database password.

    The value must be 8 to 32 characters in length and contain uppercase letters (A to Z), lowercase letters (a to z), digits (0 to 9), and special characters, such as ~!@#%^*-_=+?

    Enter a strong password to improve security, preventing security risks such as brute force cracking.

    If this parameter is not transferred, set a password for the instance before connecting to the instance. For details, see Resetting the Administrator Password.

    disk_encryption_id

    String

    No

    The key ID used for disk encryption. The string must comply with UUID regular expression rules.

    If this parameter is not transferred, disk encryption is not performed.

    configurations

    Array of objects

    No

    Parameter group configuration information. For more information, see Table 4.

    If this parameter is not transferred, the default parameter group is used.

    flavor

    Array of objects

    Yes

    Instance specifications. For more information, see Table 5.

    For details about how to obtain the value, see the parameter value in Querying Database Specifications.

    restore_point

    Object

    Yes

    The details about the backup to be restored to a new DB instance. For more information, see Table 3.

    backup_strategy

    Object

    No

    Advanced backup policy. For more information, see Table 6.

    enterprise_project_id

    String

    No

    Enterprise project ID.

    • This parameter is not transferred for users who have not enabled the enterprise multi-project service.
    • If this parameter is not transferred for a user who has enabled the enterprise multi-project service, the value is the default enterprise project.

    ssl_option

    String

    No

    Whether to enable or disable SSL.

    Valid value:

    • The value 0 indicates that SSL is disabled by default.
    • The value 1 indicates that SSL is enabled by default.

    If this parameter is not transferred, SSL is enabled by default.

    dss_pool_id

    String

    No

    The dedicated storage ID of the DeC user. The value is left blank by default. Only DeC users can set this parameter.

    server_group_policies

    Array of strings

    No

    The names of the policies associated with the ECS group of the DeC user. Available values include:

    • anti-affinity indicates that anti-affinity deployment is enabled for the DDS instance. To ensure high availability, the primary, secondary, and hidden nodes are created on different physical machines.

    If this parameter is not transferred for DeC users, anti-affinity deployment is disabled by default. Only DeC users can set this parameter.

    charge_info

    Object

    No

    Billing mode, which includes yearly/monthly and pay-per-use. The default billing mode is pay-per-use.

    For details, see Table 7.

    Table 3 Data structure description of the restore_point field

    Name

    Type

    Mandatory

    Description

    instance_id

    String

    No

    The instance ID, which can be obtained by calling the API for querying instances. If you do not have an instance, you can call the API used for creating an instance.

    • This parameter is optional when type is set to backup.
    • This parameter is mandatory when type is set to timestamp.

    type

    String

    No

    The recovery mode. The enumerated values are as follows:

    • backup: indicates restoration from backup files. In this mode, backup_id is mandatory when type is optional.
    • timestamp: indicates point-in-time restoration. In this mode, restore_time is mandatory when type 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.

    NOTE:

    When type is not mandatory, backup_id is mandatory.

    restore_time

    Integer

    No

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

    NOTE:

    When type is mandatory, restore_time is mandatory.

    Table 4 Data structure description of the configurations field

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    The node type. Valid value:

    • For a cluster instance, the value can be mongos, shard, or config.
    • For a replica set instance, the value is replica.
    • For a single node instance, the value is single.

    Enumerated values:

    • mongos
    • shard
    • config
    • replica
    • single

    configuration_id

    String

    Yes

    Parameter group ID

    Table 5 Data structure of the flavor field

    Name

    Type

    Mandatory

    Description

    type

    String

    Yes

    The node type.

    Valid value:

    • For a cluster instance, the value can be mongos, shard, or config.
    • For a replica set instance, the value is replica.
    • For a single node instance, the value is single.

    num

    String

    Yes

    The node quantity.

    Valid value:

    • In a cluster instance, the number of mongos nodes ranges from 2 to 32.
    • config: The value is 1.
    • replica: The value is 1.
    • single: The value is 1.

    size

    String

    No

    The disk size.

    The value must be a multiple of 10. The unit is GB.

    • In a cluster instance, the shard size ranges from 10 GB to 2000 GB and must be greater than or equal to the disk size of the original instance. The config size can only be 20 GB. This parameter is invalid for mongos nodes. Therefore, you do not need to specify the storage space for mongos nodes.
    • In a replica set instance, the disk size ranges from 10 GB to 3000 GB and must be greater than or equal to the disk size of the original instance.
    • In a single node instance, the disk size ranges from 10 GB to 1000 GB and must be greater than or equal to the disk size of the original instance.

    spec_code

    String

    Yes

    The resource specification code. For details about how to obtain the value, see the parameter value in Querying Database Specifications.

    Table 6 backup_strategy field data structure description

    Name

    Type

    Mandatory

    Description

    start_time

    String

    Yes

    The backup time window. Automated backups will be triggered during the backup time window.

    The value cannot be empty. It must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.

    • The HH value must be 1 greater than the hh value.
    • The values of mm and MM must be the same and must be set to 00.

    Example value:

    23:00-00:00

    keep_days

    String

    No

    The number of days to retain the generated backup files.

    The value range is from 0 to 732.

    • If this parameter is set to 0, the automated backup policy is not set.
    • If this parameter is not transferred, the automated backup policy is enabled by default. Backup files are stored for seven days by default.
    Table 7 Data structure of the ChargeInfo field

    Parameter

    Type

    Mandatory

    Description

    charge_mode

    String

    Yes

    Billing mode. Value range:

    • prePaid: indicates the yearly/monthly billing mode.
    • postPaid: indicates the pay-per-use billing mode.

    period_type

    String

    No

    Subscription period. This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:

    • month: The service is subscribed by month.
    • year: The service is subscribed by year.

    period_num

    Integer

    No

    This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:

    • If period_type is set to month, the parameter value ranges from 1 to 9.
    • If period_type is set to year, the parameter value ranges from 1 to 3.

    is_auto_renew

    Boolean

    No

    Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal. Value range:

    • true: indicates that the subscription is automatically renewed.
    • false: indicates that the subscription is not automatically renewed. The default value is false.

    is_auto_pay

    Boolean

    No

    Payment method. When creating a yearly/monthly DB instance, you can specify whether to automatically pay with your account. This parameter does not affect the payment method of automatic renewal. Value range:

    • true: indicates that the fee is automatically paid from the account.
    • false: indicates that the fee is manually paid from the account. This payment method is used by default.

    The values of region and availability_zone are used as examples.

  • Request example

    Restoring a backup to a new cluster instance:

    {
      "name": "test-cluster-01",
      "availability_zone": "az1xahz",
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961",
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007",
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58",
      "password": "******",
      "configurations": [
        {
          "type": "mongos",
          "configuration_id": "acb288dbd1174f26a8960b45591bd98apr02"
        },
        {
          "type": "shard",
          "configuration_id": "5bca546f0be64b038124ef9cedd1bfa1pr02"
        },
        {
          "type": "config",
          "configuration_id": "4d123b3ba8294921802b11bf4d8c5735pr02"
        }
      ],
      "restore_point": {
        "backup_id": "8f643d252d834a4c916b2db4322f99552734"
      },
      "flavor": [
        {
          "type": "mongos",
          "num": "2",
          "spec_code": "dds.mongodb.c6.medium.4.mongos"
        },
        {
          "type": "shard",
          "size": "20",
          "spec_code": "dds.mongodb.c6.medium.4.shard"
        },
        {
          "type": "config",
          "num": "1",
          "size": "20",
          "spec_code": "dds.mongodb.c6.large.2.config"
        }
      ],
      "backup_strategy": {
        "start_time": "08:15-09:15",
        "keep_days": "8"
      },
      "ssl_option": "1",
      "dss_pool_id": "f5f84ed7-6f19-4bd4-99d7-b450ad6cc4dd",
      "server_group_policies": [
        "anti-affinity"
      ]
    }

    Restoring a backup to a new replica set instance:

    "name": "test-replicaset",
    "availability_zone": "az1xahz",
    "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961",
    "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007",
    "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58",
    "password": "******",
    "configurations": [
      {
        "type": "replica",
        "configuration_id": "f17e3aad778440fbb68603c8c9032003pr02"
      }
    ],
    "restore_point": {
      "backup_id": "8f643d252d834a4c916b2db4322f99552734"
    },
    "flavor": [
      {
        "type": "replica",
        "num": "1",
        "storage": "ULTRAHIGH",
        "size": "30",
        "spec_code": "dds.mongodb.s2.medium.4.repset"
      }
    ],
    "backup_strategy": {
      "start_time": "08:15-09:15",
      "keep_days": "8"
    },
    "ssl_option": "1"
    }

    Restoring a backup to a new single node instance:

    {
      "name": "test-singlenode",
      "availability_zone": "az1xahz",
      "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961",
      "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007",
      "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58",
      "password": "******",
      "configurations": [
        {
          "type": "single",
          "configuration_id": "b8e962e66ede47609a94cba591735b49pr02"
        }
      ],
      "restore_point": {
        "backup_id": "8f643d252d834a4c916b2db4322f99552734"
      },
      "flavor": [
        {
          "type": "single",
          "num": "1",
          "storage": "ULTRAHIGH",
          "size": "30",
          "spec_code": "dds.mongodb.c6.medium.4.single"
        }
      ],
      "backup_strategy": {
        "start_time": "08:15-09:15",
        "keep_days": "8"
      },
      "ssl_option": "1"
    }

    Restoring a backup to a new replica set instance at a point in time:

    {
      "name": "replica-liuyunj1",
      "availability_zone": "az1xahz",
      "vpc_id": "dcdadabc-efed-4518-8b34-4af66fcd97e7",
      "subnet_id": "4a9348f2-f232-4700-a440-2f1641d80960",
      "security_group_id": "c57b9db2-cccb-4c0d-b058-7ea51dda0c99",
      "flavor": [
        {
          "type": "replica",
          "num": 1,
          "size": 100,
          "spec_code": "dds.mongodb.c6.large.2.repset"
        }
      ],
      "backup_strategy": {
        "start_time": "08:00-09:00",
        "keep_days": "8"
      },
      "restore_point": {
        "instance_id": "d5833c2854a4486cb7960f829269e211in02",
        "type": "timestamp",
        "restore_time": 1607689584000
      },
      "ssl_option": "1"
    }

Responses

  • Parameter description
    Table 8 Parameter description

    Name

    Type

    Mandatory

    Description

    id

    String

    No

    The DB instance ID.

    name

    String

    No

    Instance name, which is the same as the request parameter.

    datastore

    Object

    No

    Database information, which is the same as the request parameter. For more information, see Table 3.

    created

    String

    No

    Creation time, which is in the yyyy-mm-dd hh:mm:ss format.

    status

    String

    No

    The DB instance status. The value is creating.

    region

    String

    No

    Region ID, which is the same as the request parameter.

    availability_zone

    String

    No

    AZ ID, which is the same as the request parameter.

    vpc_id

    String

    No

    VPC ID, which is the same as the request parameter.

    subnet_id

    String

    No

    Subnet ID, which is the same as the request parameter.

    security_group_id

    String

    No

    The ID of the security group to which the instance belongs. It is the same as the request parameter.

    disk_encryption_id

    String

    No

    The ID of the disk encryption key. It is the same as the request parameter.

    mode

    String

    No

    Instance type, which is the same as the request parameter.

    configurations

    Array of objects

    No

    Parameter group configuration information.

    For details, see Table 9.

    flavor

    Array of objects

    No

    Instance specification, which is the same as the request parameter. For more information, see Table 5.

    backup_strategy

    Object

    No

    Advanced backup policy, which is the same as the request parameter. For more information, see Table 6.

    enterprise_project_id

    String

    No

    Enterprise project ID. If the value is 0, the resource belongs to the default enterprise project.

    dss_pool_id

    String

    No

    The DSS storage pool ID of the DeC user.

    job_id

    String

    No

    The ID of the workflow for creating a DB instance.

    ssl_option

    String

    No

    Indicates whether to enable SSL, which functions the same as the request parameter.

    order_id

    String

    No

    The ID of the order for creating an instance. This parameter is returned only when you create a yearly/monthly instance.

    charge_info

    Object

    No

    Billing mode, which is the same as the request parameter.

    For details, see Table 10.

    Table 9 Data structure description of the configurations field

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    The node type. Valid value:

    • For a cluster instance, the value can be mongos, shard, or config.
    • For a replica set instance, the value is replica.
    • For a single node instance, the value is single.

    Enumerated values:

    • mongos
    • shard
    • config
    • replica
    • single

    configuration_id

    String

    Yes

    Parameter group ID

    Table 10 Data structure of the ChargeInfo field

    Parameter

    Type

    Mandatory

    Description

    charge_mode

    String

    Yes

    Billing mode. Value range:

    • prePaid: indicates the yearly/monthly billing mode.
    • postPaid: indicates the pay-per-use billing mode.

    period_type

    String

    No

    Subscription period. This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:

    • month: The service is subscribed by month.
    • year: The service is subscribed by year.

    period_num

    Integer

    No

    This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:

    • If period_type is set to month, the parameter value ranges from 1 to 9.
    • If period_type is set to year, the parameter value ranges from 1 to 3.

    is_auto_renew

    Boolean

    No

    Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal. Value range:

    • true: indicates that the subscription is automatically renewed.
    • false: indicates that the subscription is not automatically renewed. The default value is false.

    is_auto_pay

    Boolean

    No

    Payment method. When creating a yearly/monthly DB instance, you can specify whether to automatically pay with your account. This parameter does not affect the payment method of automatic renewal. Value range:

    • true: indicates that the fee is automatically paid from the account.
    • false: indicates that the fee is manually paid from the account. This payment method is used by default.

    The values of region and availability_zone are used as examples.

  • Response example

    Cluster instance:

    {
      "id": "39b6a1a278844ac48119d86512e0000bin02",
      "name": "test-cluster-01",
      "datastore": {
        "type": "DDS-Community",
        "version": "3.4",
        "storage_engine": "wiredTiger"
      },
      "created": "2019-01-16 09:34:36",
      "status": "creating",
      "region": "aaa",
      "availability_zone": "az1xahz",
      "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
      "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f",
      "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5",
      "disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4",
      "mode": "Sharding",
      "configurations": [
        {
          "type": "mongos",
          "configuration_id": "acb288dbd1174f26a8960b45591bd98apr02"
        },
        {
          "type": "shard",
          "configuration_id": "5bca546f0be64b038124ef9cedd1bfa1pr02"
        },
        {
          "type": "config",
          "configuration_id": "4d123b3ba8294921802b11bf4d8c5735pr02"
        }
      ],
      "flavor": [
        {
          "type": "mongos",
          "num": "2",
          "spec_code": "dds.mongodb.c6.medium.4.mongos"
        },
        {
          "type": "shard",
          "num": "2",
          "spec_code": "dds.mongodb.c6.medium.4.shard",
          "size": "20"
        },
        {
          "type": "config",
          "num": "1",
          "spec_code": "dds.mongodb.c6.large.2.config",
          "size": "20"
        }
      ],
      "backup_strategy": {
        "start_time": "08:15-09:15",
        "keep_days": "8"
      },
      "enterprise_project_id": "",
      "ssl_option": "1",
      "dss_pool_id": "f5f84ed7-6f19-4bd4-99d7-b450ad6cc4dd",
      "job_id": "c010abd0-48cf-4fa8-8cbc-090f093eaa2f"
    }

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.