You can call the CopyDatabaseBetweenInstances operation to replicate databases from one instance to another.
You can also call this operation to restore specific databases to an existing instance by point in time or backup set. For more information, see Restore the data of an ApsaraDB RDS for SQL Server instance.
Before you call this operation, make sure that the following requirements are met:
- The source and destination instances belong to the same account.
- The source and destination instances run the same version of database engine.
- The source and destination instances reside in the same region and use the same network type. Their zones can be different.
- The source and destination instances do not have databases whose names are the same.
- The available storage of the destination instance is larger than the total size of the databases that you want to replicate from the source instance.Note This operation is applicable only to instances that run SQL Server 2012 or later.
Debugging
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":"newtest1","test2":"newtest2"} | The names of the databases. Format: |
| BackupId | String | No | 106523874**** | The ID of the backup set by which you want to restore databases of the source instance. When you replicate databases by backup set, you can call the DescribeBackups operation to obtain the ID of the backup set. Note You need to only specify one of the BackupId and RestoreTime parameters. |
| RestoreTime | String | No | 2011-06-11T16:00:00Z | The point in time when the system replicates databases. You can select a point in time within the 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 You need to only specify one of the BackupId and RestoreTime parameters. |
| SyncUserPrivilege | String | No | NO | Specifies whether to copy users and permissions.
Default value: NO. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| 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":"newtest1","test2":"newtest2"}
&BackupId=106523874****
&RestoreTime=2011-06-11T16:00:00Z
&SyncUserPrivilege=NO
&Common request parameters
Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CopyDatabaseBetweenInstancesResponse>
<RequestId>803D11AF-C370-465B-AB46-CB3A642DC303</RequestId>
</CopyDatabaseBetweenInstancesResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "803D11AF-C370-465B-AB46-CB3A642DC303"
}
Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | InvalidBackupSetID | Invalid backup set id. | The error message returned because the backup set does not exist. You can call the DescribeBackups operation to query the existing backup sets of an instance. |
| 400 | DBCountLimitExceeded | Db count limit exceeded. | The error message returned because the number of databases exceeds the upper limit. |
| 400 | BackupRestoreNotSupported.BasicHA | Basic instances cannot be restored to high availability instances, and high availability instances cannot be restored to basic instances. | The error message returned because the data cannot be restored from an instance on RDS Basic Edition to an instance on RDS High-availability Edition and vice versa. |
| 400 | BackupRestoreNotSupported.HADedicatedAlwaysOn | High availability instances cannot be restored to dedicated cluster instances or AlwaysOn instances. | The error message returned because the data of an instance on RDS High-availability Edition cannot be restored to an instance that is deployed in a dedicated cluster or runs RDS Enterprise Edition. |
| 400 | BackupRestoreNotSupported.ShareDedicatedAlwaysOn | Shared instances cannot be restored to dedicated cluster instances, AlwaysOn instances, or high availability instances. | The error message returned because the data of a shared instance cannot be restored to an instance that is deployed in a dedicated cluster or to an RDS instance that runs RDS Enterprise Edition or RDS High-availability Edition. |
| 400 | OperationDenied.RestoreTime | The instance with snapshot backup enabled can only be restored to the instance with snapshot backup enabled. | The error message returned because the data of an instance for which the snapshot backup feature is enabled can be restored only to another instance with the snapshot backup feature enabled. |
| 400 | OperationDenied.SnapshotBackupSet | Snapshot backup set can only be restored to the instance with snapshot backup enabled. | When you restore data of an instance for which the snapshot backup feature is enabled to another instance with the snapshot backup feature enabled, make sure that the instance whose type of the backup set is snapshot. |
| 400 | CanNotCopyDBHasTDEEnabled | The source database has enabled the TDE feature. You cannot copy it to another instance. | The error message returned because the data of the source instance cannot be replicated to another instance when Transparent Data Eencryption (TDE) is enabled for the source instance. |
| 400 | InvalidBackupDBNames.NotFound | The specified BackupDBNames is not found. | The error message returned because the name of the instance is not specified. |
| 400 | InvalidBackupDBNames.Malformed | The specified backup database is not valid. | The error message returned because the database that is specified for backup is invalid. |
| 400 | InvalidDBName.Format | Specified DB name is not valid. | The error message returned because the name of the database is invalid. Specify a valid database name. The name can be up to 16 characters in length and can contain lowercase letters, digits, and underscores (_). The name must start with a lowercase letter and end with a lowercase letter or a digit. |
| 400 | InvalidDBInstanceName.NotFound | Invalid DBInstanceId NotFound. | The error message returned because the ID of the instance cannot be found. |
| 400 | EngineNotSupported | The engine does not support the operation. | The error message returned because the operation is not supported for the database engine that is run on the instance. |
| 400 | InvalidTargetDBInstanceName.Format | Specified Target DB instance name is not valid. | The error message returned because the name of the destination instance is incorrect. |
| 400 | MasterDBInstanceState.NotSupport | The Master instance state does not support this operation. | The error message returned because the operation is not supported when the instance is in the current state. |
| 400 | TargetInstanceEngineNotSupported | The specified Engine cannot be supported the operation. | The error message returned because the operation is not supported by the database engine. |
| 400 | InvalidInstancesRegion.Malformed | The instance region is not the same as the target instance region. | The error message returned because the region of the destination instance is different from the region of the source instance. |
| 400 | InvalidStartTime.Format | The specified parameter "StartTime" is not valid. | The error message returned because the format of the start time is incorrect. Specify the time in GMT in the YYYY-MM-DDThh:mmZ format. Examples: DescribeDBInstancePerformance: 2012-06-11T15:00Z. DescribeErrorLogs: 2011-06-11T16:00Z. |
| 400 | InvalidEndTime.Format | The specified parameter "EndTime" is not valid. | The error message returned because the format of the end time is invalid. Specify the time in GMT in the YYYY-MM-DDThh:mmZ format. Example: 2012-06-11T15:00Z. |
| 400 | InvalidParameterCombination | The end time must be greater than the start time | The error message returned because the end time must be later than the start time. |
| 400 | InvalidBackupSetLocation.Format | Specified backup set location is not valid. | The error message returned because the specified directory of the backup set is invalid. |
| 400 | InvalidCrossRegionTrans | Cross region instance trans is not supported | The error message returned because the source instance and the destination instance reside in different regions. |
| 400 | ErrorParametersConflict | Parameter BackupsetID and restoretime can only exist one. | The error message returned because only the BackupID parameter or the Restoretime parameter can be specified. |
| 400 | InvalidDBName.NotFound | Specified DB name does not exist. | The error message returned because the specified username of the database account does not exist. Enter a correct username. |
| 400 | InvalidDBName.Duplicate | Specified DB name already exists in the This instance. | The error message returned because the name of the specified database already exists in the instance. Change the name of the specified database. |
| 400 | ReadDBInstanceNotSupport | The operation is not permitted due to type of the instance. | The error message returned because the operation is not supported by read-only instances. |
| 400 | InvalidRecoveryDbInstance.StorageSize | The disk space of the new instance cannot be less than that of the current instance | The error message returned because the available storage of the destination instance must be greater than or equal to the total size of data that is stored in the source instance. |
| 400 | InvalidRecoveryDBNames.Format | The specified parameter DBNames is not valid. | The error message returned because the name of the instance is invalid. Check the name of the instance. |
| 400 | InvalidBackupIdOrRestoreTime.NotFound | The specified parameter BackupId or RestoreTime is not valid. | The error message returned because the value of the BackupId parameter or the RestoreTime parameter is invalid. |
| 400 | Forbidden.RegionNotFound | The provided RegionId does not exist in our record. | The error message returned because the specified region ID cannot be found. |
| 400 | ImageNotFound | The specified Image is disabled or is deleted. | The error message returned because the specified image is disabled or deleted. |
| 400 | InvalidZone.NotSupportedForStorageType | The specified zone is closed or invalid for Specified DBInstanceStorageType. | The error message returned because the specified zone is no longer available or the value that is specified for the DBInstanceStorageType parameter is invalid. |
| 400 | InvalidEngineOrEngineVersion | The specified params engine or engineVersion should not be null. | The error message returned because the Engine parameter or the EngineVersion parameter is set to null. |
| 400 | InvalidGeneralGroupNameOrGdnInstanceName | The specified params generalGroupName or gdnInstanceName should not be null. | The error message returned because the generalGroupName parameter or the gdInsttanceName parameter is empty. |
| 400 | InvalidVSwitchId.NotFound | Specified virtual switch is not found in specified VPC. | The error message returned because no vSwitches are available in the virtual private cloud (VPC). |
| 400 | CDDC.TargetHostIDNotAvailable | The target host ID is not available. | The error message returned because the host is unavailable. Specify a different host. |
| 400 | CDDC.AvailableHostsNotEnoughInZone | Not enough available hosts are in the target zone. | The error message returned because no hosts are available in the specified zone. Create a host in the zone and try again. |
| 400 | ReadOnlyInstanceNotSupport | Specified ReadOnly Instance not support this operation. | The error message returned because the operation is not supported by read-only instances. |
| 400 | InvalidShareDbInstanceClassNotSupport | The current instance classType is not support operation. | The error message returned because the operation is not supported for the specified instance type. |
| 400 | InvalidQuantity.NotSupported | The specified instance quantity is not supported. | The error message returned because the number of instances exceeds the upper limit. Check the number of instances. |
| 400 | IncorrectMasterDBInstanceState | Master instance state does not support this operation. | The error message returned because the operation is not supported when the primary instance is in the current state. |
| 400 | InvalidDBInstance.ReadDBInstanceExceeded | Current DB Instance exceeding the allowed amount of read instance. | The error message returned because the number of read-only instances exceeds the upper limit. Reduce the number of read-only instances. If the memory capacity of an instance that runs MySQL is greater than 64 GB, up to 10 read-only instances can be created for the instance. If the memory capacity of the instance is less than or equal to 64 GB, up to five read-only instances can be created for the instance. |
| 400 | InvalidEngineVersion.Malformed | Specified engine version is not valid. | The error message returned because the specified version of the database engine is invalid. Check the version of the database engine and try again. |
| 400 | InvalidEssdStorageSize | The cloud ESSD storage size is invalid. | The error message returned because the storage capacity that is specified for the instance with standard SSDs or enhanced SSDs (ESSDs) is invalid. Select a valid storage capacity and try again. |
| 400 | IncorrectInstanceNetworkType | The specified parameter InstanceNetworkType is not valid. | The error message returned because the value of the InstanceNetworkType parameter is invalid. |
| 400 | AtLeastTwoVSwitchParamExists | The specified params(Vswitchs) at least two. | Specify at least two values for the Vswitchs parameter. Make sure that the number of vSwitches is the same as that of zones. |
| 403 | StorageLimitExceeded | Exceeding the allowed Storage of DB instance. | The error message returned because the new storage capacity exceeds the upper limit. Clear the disk space. |
| 403 | InvalidTempInstance.NotSupport | The temp db Instance is not support. | The error message returned because the instance is locked. |
| 403 | IncorrectDBInstanceState | The current database instance state does not support the operation. | The error message returned because the operation is not supported when the instance is in the current state. Check whether the instance is in the Running state. |
| 403 | IncorrectDBInstanceType | Current DB instance engine and type does not support operations. | The error message returned because the operation is not supported for the database engine and instance type of the instance. |
| 403 | Forbidden.SnapshotRecovery | Snapshot backup does not support partial restore | The error message returned because snapshot backups cannot be used to restore only a specific part of data. |
| 403 | OperationDenied.Resource | Specified DB instance class or storage is not available in all Availability Zones. | The error message returned because the resource inventory is insufficient. Change the instance type and storage capacity of the instance and try again. |
| 403 | ReadonlyDBInstanceStorageExceeded | You can not create the order with the db instance because The masterInstance storage value exceeding the readonlyInstance storage value. | The error message returned because the storage capacity of the primary instance is greater than the storage capacity of its read-only instance, and you cannot use the instance to create an order. |
| 403 | MasterDBInstanceClassNotSupport | You can not create the readonly instance with the db instance class does not support. | The error message returned because the read-only instance cannot be created by using the parameter that is not supported by the primary instance. |
| 403 | ReadonlyDBInstanceClassNotSupport | You can not create the readonly instance with the master instance class does not support. | The error message returned because the read-only instance cannot be created by using the option that is not supported by the instance. |
| 403 | ReadonlyDBInstanceClassLowerThanMasterInstance | The readonly instance db instance class are lower than master instance db instance class. | The error message returned because the specifications of the read-only instance are lower than the specifications of the primary instance. |
| 403 | InvalidSwitchType.Malformed | The specified parameter InvalidSwitchType is not valid. | The error message returned because the value of the InvalidSwitchType parameter is invalid. |
| 403 | UnsupportedCopyDbHighAvailabilityToBasic | Replicate Database from RDS Category:HighAvailability to RDS Category:Basic is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS High-availability Edition to an instance that runs RDS Basic Edition. |
| 403 | InvalidInstanceVersion | Source instance version is greater than the target instance version. | The error message returned because the database engine version of the source instance is later than that of the destination instance. |
| 403 | UnsupportedCopyDbShareToHighAvailability | Replicate Database from RDS Category:Share to RDS Category:HighAvailability is not supported. | The error message returned because the database cannot be replicated from a shared instance to an instance that runs RDS High-availability Edition. |
| 403 | UnsupportedCopyDbAlwaysOnToBasic | Replicate Database from RDS Category:AlwaysOn to RDS Category:Basic is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS Cluster Edition to an instance that runs RDS Basic Edition. |
| 403 | UnsupportedCopyDbBasicToShare | Replicate Database from RDS Category:Basic to RDS Category:Share is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS Basic Edition to a shared instance. |
| 403 | UnsupportedCopyDbAlwaysOnToHighAvailability | Replicate Database from RDS Category:AlwaysOn to RDS Category:HighAvailability is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS Cluster Edition to an instance that runs RDS High-availability Edition. |
| 403 | UnsupportedCopyDbShareToBasic | Replicate Database from RDS Category:Share to RDS Category:Basic is not supported. | The error message returned because the database cannot be replicated from a shared instance to an instance that runs RDS Basic Edition. |
| 403 | UnsupportedCopyDbHighAvailabilityToShare | Replicate Database from RDS Category:HighAvailability to RDS Category:Share is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS High-availability Edition to a shared instance. |
| 403 | UnsupportedCopyDbShareToAlwaysOn | Replicate Database from RDS Category:Share to RDS Category:AlwaysOn is not supported. | The error message returned because the database cannot be replicated from a shared instance to an instance that runs RDS Cluster Edition. |
| 403 | UnsupportedCopyDbAlwaysOnToShare | Replicate Database from RDS Category:AlwaysOn to RDS Category:Share is not supported. | The error message returned because the database cannot be replicated from an instance that runs RDS Cluster Edition to a shared instance. |
| 403 | InvalidParamTableMeta.RestoreTime | There are databases created later than the last full backup at the instance level, point-in-time restore is not possible, try to restore using a backup set or pick another database restore time. | The error message returned because the database that you want to restore is created on the instance after the last full backup is complete and data cannot be restored to the specified point in time. We recommend that you restore data by backup set or specify a database that meets requirements and restore data to the specified point in time. |
| 404 | InvalidDBInstance.NotFound | The specified instance does not exist or is not supported. | The error message returned because the specified instance cannot be found. Check the ID of the instance. |
| 404 | InvalidInstanceStorageType.NotFound | The specified DBInstanceStorageType is not found. | The error message returned because the InstanceStorageType parameter is not specified. Specify the parameter. |
| 404 | InvalidRegion.NotFound | Specified Region does not exist in the RDS | The error message returned because the region ID is invalid. |
| 404 | IncorrectVswitchId | The specified parameter VSwitchId is not valid. | The error message returned because the value of the VSwitchId parameter is invalid. |
| 404 | InsufficientResourceCapacity | Current cluster resources are insufficient. Try again later. | The error message returned because the resource inventory in the cluster is insufficient. Try again later. |
For a list of error codes, see Service error codes.