You can call this operation to copy databases from one instance to another.

This operation must meet the following requirements:

  • The source and destination instances belong to the same account.
  • The versions of the source and destination instances are the same.
  • The source and destination instances are in the same region and can belong to different zones. The network types must be the same.
  • The source and destination instances do not have databases whose names are the same.
  • The available storage space of the destination instance is larger than the size of the databases to be copied.
    Note This operation is applicable only to ApsaraDB RDS for SQL Server 2012 or 2016.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Parameter Type Required Example Description
Action String Yes CopyDatabaseBetweenInstances

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

DBInstanceId String Yes rm-uf6wjk5xxxxxxx

The ID of the source instance.

TargetDBInstanceId String Yes rm-ut5ajk3xxxxxxx

The ID of the destination instance, which must differ from the ID of the source instance.

DbNames String Yes {"test1":"test2"}

The list of database names. Format: {"source instance database name":"destination instance database name"}.

BackupId String No 1065238746521

The ID of the backup set on the source instance. When you copy databases based on the backup set, you can call DescribeBackups to obtain the backup set ID.

RestoreTime String No 2011-06-11T16:00:00Z

The time when the system copies the database. You can select any time within the backup retention period.

SyncUserPrivilege String No NO

Indicates whether to copy users and permissions.

  • YES: Copy users and permissions. If the destination instance has a user whose name is the same as that in the source instance, the user will have both its current permissions and permissions of the user in the source instance after you copy user permissions.
  • NO: Do not copy users and permissions.

Default value: NO.

Response parameters

Parameter Type Example Description
DBInstanceId String rm-uf6wjk5xxxxxxxxxx

The ID of the instance.

RequestId String 803D11AF-C370-465B-AB46-CB3A642DC303

The ID of the request.

Examples

Sample requests


http(s)://rds.aliyuncs.com/? Action=CopyDatabaseBetweenInstances
&DBInstanceId=rm-uf6wjk5xxxxxxx
&TargetDBInstanceId=rm-ut5ajk3xxxxxxx
&DbNames={"test1":"test2"}
&<Common request parameters>

Successful response examples

XML format

<CopyDatabaseBetweenInstancesResponse>
  <RequestId>803D11AF-C370-465B-AB46-CB3A642DC303</RequestId> 
</CopyDatabaseBetweenInstancesResponse>

JSON format

{
	"RequestId":"803D11AF-C370-465B-AB46-CB3A642DC303"
}

Error codes

HTTP status code Error code Error message Description
403 StorageLimitExceeded Exceeding the allowed Storage of DB instance. The error message returned when the disk space of the instance is smaller than the size of the databases to be copied.

View error codes