You can call the RestoreTable operation to restore individual databases or tables of an ApsaraDB RDS instance.

ApsaraDB RDS for MySQL supports the restoration of individual databases and tables. If you delete databases or tables from an instance, you can restore the databases or tables by using a backup file. For more information, see Restore individual databases and tables of an ApsaraDB RDS for MySQL instance.

Before you call this operation, make sure that the following requirements are met:

Note This operation is supported only by instances that run MySQL.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RestoreTable

The operation that you want to perform. Set the value to RestoreTable.

ClientToken String No ETnLKlblzczshOTUbOCzxxxxxxxxxx

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length.

DBInstanceId String Yes rm-uf6wjk5xxxxxxxxxx

The ID of the instance.

BackupId String No 9026262

The ID of the data backup file.

You can call the DescribeBackups operation to obtain the ID of the data backup file.

Note You must specify at least one of BackupId and RestoreTime parameters.
RestoreTime String No 2011-06-11T16:00:00Z

The point in time to which you want to restore data. The point in time must fall within the specified log backup retention period. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note
TableMeta String Yes [{"type":"db","name":"testdb1","newname":"testdb1_new","tables":[{"type":"table","name":"testdb1table1","newname":"testdb1table1_new"}]}]

The databases and tables that you want to restore. Format:

[{"type":"db","name":"<The name of Database 1>","newname":"<The new name of Database 1>","tables":[{"type":"table","name":"<The name of Table 1 in Database 1>","newname":"<The new name of Table 1>"},{"type":"table","name":"<The name of Table 2 in Database 1>","newname":"<The new name of Table 2>"}]},{"type":"db","name":"<The name of Database 2>","newname":"<The new name of Database 2>","tables":[{"type":"table","name":"<The name of Table 3 in Database 2>","newname":"<The new name of Table 3>"},{"type":"table","name":"<The name of Table 4 in Database 2>","newname":"<The new name of Table 4>"}]}]
InstantRecovery Boolean No true

Specifies whether to enable the fast individual database and table restoration feature. Valid values:

  • true: enables the feature.
  • false: disables the feature.

Response parameters

Parameter Type Example Description
RequestId String EA2D4F34-01A7-46EB-A339-D80882135206

The ID of the request.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=RestoreTable
&DBInstanceId=rm-uf6wjk5xxxxxxxxxx
&RestoreTime=2019-08-20T16:00:00Z
&TableMeta=[{"type":"db","name":"dtstestdata","newname":"dtstestdata","tables":[{"type":"table","name":"customer_old","newname":"customer_old123"},{"type":"table","name":"order","newname":"order123"}]}]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RestoreTableResponse>
<RequestId>EA2D4F34-01A7-46EB-A339-D80882135206</RequestId>
</RestoreTableResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "EA2D4F34-01A7-46EB-A339-D80882135206"
}

Error codes

HTTP status code Error code Error message Description
400 InvalidRestoreType.Format Specified restore type is not valid. The error message returned because the specified restoration type is invalid. You must specify a valid restoration type.
400 InvalidRestoreTime.Format Specified restore time is not valid. The error message returned because the value of the RestoreTime parameter is invalid. You must specify a valid value for the RestoreTime parameter.
400 InvalidParamTableMeta Invalid parameter TableMeta is null or not json format The error message returned because the format of the TableMeta parameter is invalid. You must specify a valid value for the TableMeta parameter.
400 InvalidBakHistoryDO BakHistory is inbalid when check restore TableMeta The error message returned because the specified data backup file is invalid and no database or table information is available.
400 InvalidParamTableMeta.Content TableMeta missing old dbname or new dbname, please check The error message returned because the value of the TableMeta parameter does not specify the tables on the original and new databases.
400 InvalidParamTableMeta.Duplicate TableMeta has duplicate db or table with other newname, commons or system The error message returned because databases and tables with the specified names already exist in the new instance.
400 InvalidSourceRestoreDBName.NotFound specific source restore dbname is not found in db list The error message returned because the specified databases cannot be found in the specified data backup file.
400 InvalidDBName.Duplicate Specified DB name already exists in the This instance. The error message returned because the name of the specified database is duplicate in the instance. You must change the name of the specified database.
400 InvalidParameters.Format Specified parameters is not valid. The error message returned because the value of a specified parameter is invalid.
400 InvalidAvZone.Format Specified AvZone is not valid. The error message returned because the value of the AvZone parameter is invalid.
400 InvalidRegion.Format Specified Region is not valid. The error message returned because the specified region is invalid.
400 InvalidVpcParameter Specified VPCId VSwitchId or IPAddress or TunnelId is not valid. The error message returned because the values of the VPCId and VSwitchId parameters are invalid.
400 MissingUserID The request is missing a user_id parameter. The error message returned because the specified user ID does not exist.
400 MissingUID The request is missing a uid parameter. The error message returned because the account that you use does not exist.
400 MissBackupSetAndRestoreTime.NotFound Both BackupSet and RestoreTime are null. The error message returned because the BackupId and RestoreTime parameters are empty.
400 InvalidBakHistory.DbVersionMismatch db version of bakhistory is mismatch with custins The error message returned because the version of the original instance is different from that of the new instance.
403 InvalidBackupLogStatus Current backup log enable status does not support this operation. The error message returned because the log backup feature is disabled and consequently data cannot be restored to a specific point in time.
403 IncorrectDBInstanceType Current DB instance type does not support this operation. The error message returned because this operation is not supported when the instance is in the current state.
403 IncorrectDBInstanceState Current DB instance state does not support this operation. The error message returned because this operation is not supported when the instance is in the current state.
403 IncorrectBackupSetMethod Current backup set method does not support operations. The error message returned because the specified data backup file cannot be used to restore individual databases and tables.
403 IncorrectBackupSetState Current backup set state does not support operations. The error message returned because this operation is not supported due to the status of the specified data backup file.
403 ChildDBInstanceExists Current DB instance had child instance. The error message returned because read-only instances are attached to the original instance.
404 InvalidBackup.NotFound The available backup does not exist in recovery time. The error message returned because no data backup files are available.
404 InvalidBinlog.NotFound The available binlog does not exist in recovery time. The error message returned because no valid binary log backup files at the specified point in time are available.
404 InvalidBackupSetID.NotFound Specified backup set ID does not exist. The error message returned because the specified data backup file does not exist. You must specify a valid data backup file.
404 InvalidDB.NotFound Specified db does not exist or DB status does not support. The error message returned because the specified databases and tables cannot be found in the specified data backup file.
404 InvalidDBInstance.NotFound Specified instance does not exist or not support. The error message returned because the instance cannot be found, is deleted, or does not support the operation.

For a list of error codes, visit the API Error Center.