If you want to replicate a database of an ApsaraDB RDS instance that runs SQL Server 2012 or later, you must execute SQL statements and specify the existing and new databases by using the sp_rds_copy_database stored procedure. The time required for replication depends on the size of the existing database.

Note For more information about how to replicate a database of an ApsaraDB RDS instance that runs SQL Server 2008 R2, see Copy a database of ApsaraDB RDS SQL Server 2008 R2.

Prerequisites

  • The RDS instance runs SQL Server 2012 or later.
  • The available storage capacity of the destination RDS instance is at least 1.3 times larger than the size of the existing database.

Procedure

Execute the following statements to replicate an existing database:

USE master
GO
--Query database engine edition
SELECT @@Version
GO
--Create database
CREATE DATABASE testdb
GO
EXEC sp_rds_copy_database 'testdb','testdb_copy'
SELECT *
FROM sys.databases
WHERE name IN ('testdb','testdb_copy')
SELECT 
    family_guid,database_guid,* 
FROM sys.database_recovery_status
WHERE 
DB_NAME(database_id) IN ('testdb','testdb_copy')