Help Center > > API Reference> API v3 (Recommended)> Backup and Restoration> Restoring Data to a New DB Instance

Restoring Data to a New DB Instance

Updated at: Apr 22, 2020 GMT+08:00

Function

This API is used to restore data to a new DB instance (v3).

Constraints

  • The DB engine of the original DB instance must be the same as that of the target DB instance. For example, if the original DB instance is running MySQL, the target DB instance must also run MySQL.
  • All DB engine versions of the original and new DB instances must be consistent.
  • The total volume size of the new DB instance must be greater than or equal to that of the original DB instance.

URI

  • URI format

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

  • Example

    https://rds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID of a tenant in a region.

    For details about how to obtain the project ID, see Obtaining a Project ID.

Request

  • Parameter description
    Table 2 Parameter description

    Name

    Mandatory

    Type

    Description

    name

    Yes

    String

    Specifies the DB instance name.

    DB instances of the same type can have same names under the same tenant, except that Microsoft SQL Server DB instances of the same type must have unique names under the same tenant.

    The value must be 4 to 64 characters in length and start with a letter. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_).

    ha

    No

    Object

    Specifies the HA configuration parameters, which are used when creating primary/standby DB instances.

    For details, see Table 3.

    configuration_id

    No

    String

    Specifies the parameter template ID.

    port

    No

    String

    Specifies the database port information.

    • The MySQL database port ranges from 1024 to 65535 (excluding 12017 and 33071, which are occupied by the RDS system and cannot be used).
    • The PostgreSQL database port ranges from 2100 to 9500.
    • The Microsoft SQL Server database port is 1433 or ranges from 2100 to 9500 (excluding 5355 and 5985). For Microsoft SQL Server 2017 Enterprise, Standard, and Web editions, the database port is 1433 or ranges from 2100 to 9500, excluding 5050, 5353, and 5986.

    If this parameter is not set, the default value is as follows:

    • For MySQL, the default value is 3306.
    • For PostgreSQL, the default value is 5432.
    • For Microsoft SQL Server, the default value is 1433.

    password

    Yes

    String

    Specifies the database password.

    Valid value:

    The value cannot be empty and should contain 8 to 32 characters, including uppercase and lowercase letters, digits, and the following special characters: ~!@#%^*-_=+?

    You are advised to enter a strong password to improve security, preventing security risks such as brute force cracking.

    backup_strategy

    No

    Object

    Specifies the advanced backup policy.

    For details, see Table 4.

    enterprise_project_id

    No

    String

    Specifies the project ID.

    disk_encryption_id

    No

    String

    Specifies the key ID for disk encryption. The default value is empty.

    flavor_ref

    Yes

    String

    Specifies the specification code. The value cannot be empty.

    For details, see spec_code in section Querying Database Specifications.

    volume

    Yes

    Object

    Specifies the volume information.

    For details, see Table 5.

    availability_zone

    Yes

    String

    Specifies the AZ ID. If the DB instance is not a single instance, you need to specify an AZ for each node of the instance and separate the AZs with commas (,). For details, see the example.

    The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

    vpc_id

    Yes

    String

    Specifies the VPC ID. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console and view the VPC ID in the VPC details.
    • Method 2: See the "Querying VPCs" section in the Virtual Private Cloud API Reference.

    subnet_id

    Yes

    String

    Specifies the network ID. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.
    • Method 2: See the "Querying Subnets" section in the Virtual Private Cloud API Reference.

    security_group_id

    No

    String

    Specifies the security group which the RDS DB instance belongs to. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.
    • Method 2: See the "Querying Security Groups" section in the Virtual Private Cloud API Reference.

    restore_point

    Yes

    Object

    Specifies the restoration information.

    For details, see Table 6.

    time_zone

    No

    String

    Specifies the UTC time zone.

    • If this parameter is not specified, the time zone of each engine is as follows:
      • RDS for MySQL Chinese mainland site and international site use UTC by default.
      • RDS for PostgreSQL Chinese mainland site and international site use UTC by default.
      • RDS for SQL Server Chinese mainland site and international site use UTC+08:00 and UTC, respectively.
    • If this parameter is specified, the value range is from UTC-12:00 to UTC+12:00 at the top of every hour. For example, the parameter can be UTC+08:00 rather than UTC+08:30.
    Table 3 ha field data structure description

    Name

    Mandatory

    Type

    Description

    mode

    Yes

    String

    Specifies the DB instance type. The value is Ha (primary/standby DB instances) and is case-insensitive.

    replication_mode

    Yes

    String

    Specifies the replication mode for the standby DB instance.

    The value cannot be empty.

    • For MySQL, the value is async or semisync.
    • For PostgreSQL, the value is async or sync.
    • For Microsoft SQL Server, the value is sync.
    NOTE:
    • async indicates the asynchronous replication mode.
    • semisync indicates the semi-synchronous replication mode.
    • sync indicates the synchronous replication mode.
    Table 4 backup_strategy field data structure description

    Name

    Mandatory

    Type

    Description

    start_time

    Yes

    String

    Specifies 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 any of the following: 00, 15, 30, or 45.

    Example value:

    • 08:15-09:15
    • 23:00-00:00

    keep_days

    No

    Integer

    Specifies the retention days for specific backup files.

    The value range is from 0 to 732. If this parameter is not specified or set to 0, the automated backup policy is disabled. To extend the retention period, contact customer service. Automated backups can be retained for up to 2562 days.

    Table 5 volume field data structure description

    Name

    Mandatory

    Type

    Description

    type

    Yes

    String

    Specifies the volume type.

    Its value can be any of the following and is case-sensitive:

    • ULTRAHIGH: indicates the SSD type.
    • ULTRAHIGHPRO: indicates the ultra-high I/O (advanced), which supports ultra-high performance (advanced) DB instances.

    size

    Yes

    Integer

    Specifies the volume size.

    Its value range is from 40 GB to 4000 GB. The value must be a multiple of 10.

    For some users, storage space ranges from 40 GB to 6000 GB. If you want to create a DB instance with storage space up to 6000 GB or scale up to 10,000 GB, contact customer service to apply for the permission.

    NOTICE:

    The volume size of the new DB instance must be greater than or equal to that of the original DB instance.

    Table 6 restore_point field data structure description

    Name

    Mandatory

    Type

    Description

    instance_id

    Yes

    String

    Specifies the DB instance ID.

    type

    Yes

    String

    Specifies the restoration mode. Enumerated values include:

    • backup: indicates restoration from backup files. In this mode, backup_id is mandatory when type is not mandatory.
    • timestamp: indicates point-in-time restoration. In this mode, restore_time is mandatory when type is mandatory.

    backup_id

    No

    String

    Specifies the ID of the backup used to restore data. This parameter must be specified when the backup file is used for restoration.

    NOTICE:

    When type is not mandatory, backup_id is mandatory.

    restore_time

    No

    Integer

    Specifies the time point of data restoration in the UNIX timestamp. The unit is millisecond and the time zone is UTC.

    NOTICE:

    When type is mandatory, restore_time is mandatory.

    database_name

    No

    Map

    This parameter applies only to the Microsoft SQL Server DB engine. If this parameter is specified, you can restore specific databases in the DB instance and customize the database names as required.

    • The new database names must be different from the original database names. If you do not customize the database names, data will be restored to the original databases by default.
      NOTICE:

      If this parameter is not specified, all databases are restored by default.

      Example value: "database_name":{"Original database name":"New database name"}

    • The new database names cannot contain the following fields (case-insensitive): rdsadmin, master, msdb, tempdb, model, and resource.
    • Each database name consists of 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.
  • Request example

    Use backup files for restoration:

    MySQL/PostgreSQL:

    {
    	"name": "targetInst",
    	"availability_zone": "bbb,ccc",
    	"ha": {
    		"mode": "ha",
    		"replication_mode": "async"
    	},
    	"flavor_ref": "rds.mysql.s1.large",
    	"volume": {
    		"type": "ULTRAHIGH",
    		"size": 40
    	},
    	"disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4",
    	"vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
    	"subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f",
    	"security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5",
    	"backup_strategy": {
    		"keep_days": 2,
    		"start_time": "19:00-20:00"
    	},
    	"password": "Demo@12345678",
    	"configuration_id": "52e86e87445847a79bf807ceda213165pr01",
    	"enterprise_project_id": "ba1f7fc8-3307-42a7-aa6f-42c8b9b8f85c",
    	"time_zone": "UTC+04:00",
    	"restore_point": {
    		"instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin01",
    		"type": "backup",
    		"backup_id": "2f4ddb93-b901-4b08-93d8-1d2e472f30fe"
    	}
    }

    Microsoft SQL Server:

    {
    	"name": "targetInst",
    	"availability_zone": "bbb,ccc",
    	"ha": {
    		"mode": "ha",
    		"replication_mode": "sync"
    	},
    	"flavor_ref": "rds.mssql.2014.se.s3.xlarge.2.ha",
    	"volume": {
    		"type": "ULTRAHIGH",
    		"size": 40
    	},
    	"disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4",
    	"vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
    	"subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f",
    	"security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5",
    	"backup_strategy": {
    		"keep_days": 2,
    		"start_time": "19:00-20:00"
    	},
    	"password": "Demo@12345678",
    	"configuration_id": "52e86e87445847a79bf807ceda213165pr04",
    	"enterprise_project_id": "ba1f7fc8-3307-42a7-aa6f-42c8b9b8f85c",
    	"time_zone": "UTC+04:00",
    	"restore_point": {
    		"instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin04",
    		"type": "backup",
    		"backup_id": "2f4ddb93-b901-4b08-93d8-1d2e472f30fe",
    		"database_name": {
    			"db1": "dbtest1",
    			"db2": ""
    		}
    	}
    }

    Use PITR for restoration:

    MySQL/PostgreSQL:

    {
    	"name": "targetInst",
    	"availability_zone": "bbb,ccc",
    	"ha": {
    		"mode": "ha",
    		"replication_mode": "async"
    	},
    	"flavor_ref": "rds.mysql.s1.large",
    	"volume": {
    		"type": "ULTRAHIGH",
    		"size": 40
    	},
    	"disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4",
    	"vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
    	"subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f",
    	"security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5",
    	"backup_strategy": {
    		"keep_days": 2,
    		"start_time": "19:00-20:00"
    	},
    	"password": "Demo@12345678",
    	"configuration_id": "52e86e87445847a79bf807ceda213165pr01",
    	"enterprise_project_id": "ba1f7fc8-3307-42a7-aa6f-42c8b9b8f85c",
    	"time_zone": "UTC+04:00",
    	"restore_point": {
    		"instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin01",
    		"type": "timestamp",
    		"restore_time": 1532001446987
    	}
    }

    Microsoft SQL Server:

    {
    	"name": "targetInst",
    	"availability_zone": "bbb,ccc",
    	"ha": {
    		"mode": "ha",
    		"replication_mode": "sync"
    	},
    	"flavor_ref": "rds.mssql.2014.se.s3.xlarge.2.ha",
    	"volume": {
    		"type": "ULTRAHIGH",
    		"size": 40
    	},
    	"disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4",
    	"vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
    	"subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f",
    	"security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5",
    	"backup_strategy": {
    		"keep_days": 2,
    		"start_time": "19:00-20:00"
    	},
    	"password": "Demo@12345678",
    	"configuration_id": "52e86e87445847a79bf807ceda213165pr04",
    	"enterprise_project_id": "ba1f7fc8-3307-42a7-aa6f-42c8b9b8f85c",
    	"time_zone": "UTC+04:00",
    	"restore_point": {
    		"instance_id": "d8e6ca5a624745bcb546a227aa3ae1cfin04",
    		"type": "timestamp",
    		"restore_time": 1532001446987,
    		"database_name": {
    			"db1": "dbtest1",
    			"db2": ""
    		}
    	}
    }

Response

  • Normal response
    Table 7 Parameter description

    Name

    Type

    Description

    instance

    Object

    Indicates the DB instance information.

    For details, see Table 8.

    job_id

    String

    Indicates the ID of the DB instance creation task.

    Table 8 instance description

    Name

    Type

    Description

    id

    String

    Indicates the DB instance ID.

    name

    String

    Indicates the DB instance name.

    DB instances of the same type can have same names under the same tenant, except that Microsoft SQL Server DB instances of the same type must have unique names under the same tenant.

    The value must be 4 to 64 characters in length and start with a letter. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_).

    status

    String

    Indicates the DB instance status. For example, BUILD indicates that the DB instance is being created.

    datastore

    Object

    Indicates the database information.

    For details, see Table 9.

    ha

    Object

    Indicates the HA configuration parameters. This parameter is returned only when primary/standby DB instances are created.

    For details, see Table 10.

    configuration_id

    String

    Indicates the parameter template ID. This parameter is returned only when a custom parameter template is used during DB instance creation.

    port

    String

    Indicates the database port information.

    • The MySQL database port ranges from 1024 to 65535 (excluding 12017 and 33071, which are occupied by the RDS system and cannot be used).
    • The PostgreSQL database port ranges from 2100 to 9500.
    • The Microsoft SQL Server database port is 1433 or ranges from 2100 to 9500 (excluding 5355 and 5985). For Microsoft SQL Server 2017 Enterprise, Standard, and Web editions, the database port is 1433 or ranges from 2100 to 9500, excluding 5050, 5353, and 5986.

    If this parameter is not set, the default value is as follows:

    • For MySQL, the default value is 3306.
    • For PostgreSQL, the default value is 5432.
    • For Microsoft SQL Server, the default value is 1433.

    backup_strategy

    Object

    Indicates the automated backup policy.

    For details, see Table 11.

    enterprise_project_tag

    String

    Indicates the project ID.

    flavor_ref

    String

    Indicates the specification ID.

    For details, see spec_code in Table 3 in section Querying Database Specifications.

    volume

    Object

    Indicates the volume information.

    For details, see Table 12.

    region

    String

    Indicates the region ID.

    availability_zone

    String

    Indicates the AZ ID.

    vpc_id

    String

    Indicates the VPC ID. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console and view the VPC ID in the VPC details.
    • Method 2: See the "Querying VPCs" section in the Virtual Private Cloud API Reference.

    subnet_id

    String

    Indicates the network ID. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.
    • Method 2: See the "Querying Subnets" section in the Virtual Private Cloud API Reference.

    security_group_id

    String

    Indicates the security group which the RDS DB instance belongs to. To obtain this parameter value, use either of the following methods:

    • Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.
    • Method 2: See the "Querying Security Groups" section in the Virtual Private Cloud API Reference.
    Table 9 datastore field data structure description

    Name

    Mandatory

    Type

    Description

    type

    Yes

    String

    Indicates the DB engine. Its value can be any of the following and is case-insensitive:

    • MySQL
    • PostgreSQL
    • SQLServer

    version

    Yes

    String

    Indicates the database version.

    For details about supported database versions, see section Database Version Queries.

    Table 10 ha field data structure description

    Name

    Mandatory

    Type

    Description

    mode

    Yes

    String

    Indicates the DB instance type. The value is Ha (primary/standby DB instances).

    replication_mode

    Yes

    String

    Indicates the replication mode for the standby DB instance.

    The value cannot be empty.

    • For MySQL, the value is async or semisync.
    • For PostgreSQL, the value is async or sync.
    • For Microsoft SQL Server, the value is sync.
    NOTE:
    • async indicates the asynchronous replication mode.
    • semisync indicates the semi-synchronous replication mode.
    • sync indicates the synchronous replication mode.
    Table 11 backupStrategy field data structure description

    Name

    Mandatory

    Type

    Description

    start_time

    Yes

    String

    Indicates 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 any of the following: 00, 15, 30, or 45.

    Example value:

    • 08:15-09:15
    • 23:00-00:00

    keep_days

    No

    Integer

    Indicates the retention days for specific backup files.

    The value range is from 0 to 732. If this parameter is not specified or set to 0, the automated backup policy is disabled. To extend the retention period, contact customer service. Automated backups can be retained for up to 2562 days.

    Table 12 volume field data structure description

    Name

    Mandatory

    Type

    Description

    type

    Yes

    String

    Indicates the volume type.

    Its value can be any of the following and is case-sensitive:

    • ULTRAHIGH: indicates the SSD type.

    size

    Yes

    Integer

    Indicates the volume size.

    Its value range is from 40 GB to 4000 GB. The value must be a multiple of 10.

    For some users, storage space ranges from 40 GB to 6000 GB. If you want to create a DB instance with storage space up to 6000 GB or scale up to 10,000 GB, contact customer service to apply for the permission.

  • Example normal response
    {
    	"instance": {
    		"id": "f5ffdd8b1c98434385eb001904209eacin01",
    		"name": "demoname",
    		"status": "BUILD",
    		"datastore": {
    			"type": "MySQL",
    			"version": "5.6.41"
    		},
    		"port": "3306",
    		"volume": {
    			"type": "ULTRAHIGH",
    			"size": "40"
    		},
    		"region": "aaa",
    		"backup_strategy": {
    			"start_time": "02:00-03:00",
    			"keep_days": "7"
    		},
    		"flavor_ref": "rds.mysql.s1.large",
    		"availability_zone": "bbb",
    		"vpc_id": "19e5d45d-70fd-4a91-87e9-b27e71c9891f",
    		"subnet_id": "bd51fb45-2dcb-4296-8783-8623bfe89bb7",
    		"security_group_id": "23fd0cd4-15dc-4d65-bdb3-8844cc291be0"
    	},
    	"job_id": "bf003379-afea-4aa5-aa83-4543542070bc"
    }
  • Abnormal Response

    For details, see Abnormal Request Results.

Status Code

For details, see Status Codes.

Error Code

For details, see Error Codes.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel