Partager via


Start Database Copy (classic)

 

THIS TOPIC APPLIES TO: noSQL Server yesAzure SQL DatabaseyesAzure SQL Data Warehouse noParallel Data Warehouse

Important

The recommended REST commands to work with SQL Database are the Resource Manager based Azure SQL Database REST API. While there is no change to SQL Database, be aware that the classic deployment model command in this article is scheduled for deprecation on December 1, 2019. For a table providing links to the specific new commands you should use, see Operations for Azure SQL Databases.

Starts a one-time copy or a continuous copy of a specific Azure SQL Database. The original database is the 'source' database; the copy is the 'secondary' or 'target' database. For a continuous copy, the source and target databases cannot reside on the same server, and the source and target servers must be part of the same subscription.

When IsContinuous is set to False it creates a one-time copy of the source database. If the request is successful, the copy can still be in progress. You can monitor the operation using Get Database Copy (classic), List Database Copies (classic), or Database Operation Status (classic). When the copy is completed the state is set to ONLINE.

When IsContinuous is set to True it creates a continuous copy of the source database. To stop the operation an explicit call to Stop Database Copy (classic) is required. You can monitor the operation using Get Database Copy (classic) or List Database Copies (classic) (for the target database) or Database Operation Status (classic) (for the source database). When the copy is completed the state is set to ONLINE.

The continuous copy can be created as an online or offline database. The online continuous copy is used to configure Active Geo-Replication for Azure SQL Database. The offline continuous copy is used to configure Standard Geo-Replication for Azure SQL Database.

Request

The Start Database Copy request must be specified as follows:

  • Replace {subscriptionId} with your subscription ID.

  • Replace {serverName} with the name of the source server.

  • Replace {databaseName} with the name of the source database.

Method Request URI HTTP Version
POST https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databases/{databaseName}/databasecopies HTTP/1.1

Subsequent calls to create a copy with the same target database will result in an error.

URI Parameters

None.

Request Headers

The following table describes the required and optional request headers:

Request Header Description
x-ms-version Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01.
x-ms-client-request-id Optional. Provides a client-generated, opaque value with a 1 KB character limit. Using this header is highly recommended for correlating client-side activities with requests received by the server.

Request Body

The format of the request body for an online continuous copy is as follows:

<ServiceResource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/windowsazure">  
  <PartnerServer>muez4w94zn</PartnerServer>  
  <PartnerDatabase>dbtest1</PartnerDatabase>  
  <IsContinuous>True</IsContinuous>  
  <IsOfflineSecondary>False</IsOfflineSecondary>  
</ServiceResource>  

The format of the request body for an offline continuous copy is as follows:

<ServiceResource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/windowsazure">  
  <PartnerServer>muez4w94zn</PartnerServer>  
  <PartnerDatabase>dbtest1</PartnerDatabase>  
  <IsContinuous>True</IsContinuous>  
  <IsOfflineSecondary>True</IsOfflineSecondary>  
</ServiceResource>  

The format of the request body for a one-time database copy is as follows:

<ServiceResource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/windowsazure">  
  <PartnerServer>cjxrvozmbh</PartnerServer>  
  <PartnerDatabase>dbtest2</PartnerDatabase>  
  <IsContinuous>False</IsContinuous>  
  <IsOfflineSecondary>False</IsOfflineSecondary>  
</ServiceResource>  

The following table describes the elements in the request body:

PartnerServer The target server name for the copy. If IsContinuous is True, the target server must be different than the source server. If IsContinuous is False, the target server can be the same as the source server. The target server must be part of the same Azure subscription as the source server.
PartnerDatabase The target database name for the copy. If IsContinuous is True, the target database name must be the same as the source database name. If IsContinuous is False, the target database name can be different than the source database name. When creating a one-time copy within the same server the target database name must be different than the source database.
IsContinuous When True specifies that the copy should be a continuous copy. When False specifies that the copy should be a one-time copy.
IsOfflineSecondary When False, specifies that the copy should be the online continuous copy. This is used to configure Active Geo-Replication for Azure SQL Database. This option is valid only when IsContinuous=True.

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Header Description
x-ms-request-id A value that uniquely identifies a request made against the database management service. This request id is used for request tracking. If a failure occurs that requires the user to contact Microsoft Support, the request id should be provided to Microsoft to assist in tracking and resolving the failure for the request.

Response Body

The following is an example response body for an online continuous copy:

<ServiceResource xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
  <Name>5f2f5852-7a04-4f80-8d47-42a143e8aaed</Name>  
  <Type>Microsoft.SqlAzure.DatabaseCopy</Type>  
  <State>Normal</State>  
  <SelfLink="">https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/cjxrvozmbh/databases/dbtest1/databasecopies/5f2f5852-7a04-4f80-8d47-42a143e8aaed</SelfLink>  
  <ParentLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/cjxrvozmbh/databases/dbtest1</ParentLink>  
  <SourceServerName>cjxrvozmbh</SourceServerName>  
  <SourceDatabaseName>dbtest1</SourceDatabaseName>  
  <DestinationServerName>muez4w94zn</DestinationServerName>  
  <DestinationDatabaseName>dbtest1</DestinationDatabaseName>  
  <IsContinuous>True</IsContinuous>  
  <IsOfflineSecondary>False</IsOfflineSecondary>  
  <IsTerminationAllowed>False</IsTerminationAllowed>  
  <StartDate>2014-04-07T20:57:09.1600000Z</StartDate>  
  <ModifyDate>2014-04-07T20:57:09.1600000Z</ModifyDate>  
  <PercentComplete="">0</PercentComplete>  
  <ReplicationState>0</ReplicationState>  
  <ReplicationStateDescription="">PENDING</ReplicationStateDescription>  
  <LocalDatabaseId>5</LocalDatabaseId>  
  <IsLocalDatabaseReplicationTarget>False</IsLocalDatabaseReplicationTarget>  
  <IsInterlinkConnected="">True</IsInterlinkConnected>  
</ServiceResource>  

The following is an example response body for a one-time database copy:

<ServiceResource xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
  <Name>dfd31d9d-ef22-43e8-9054-d86cd3804b58</Name>  
  <Type>Microsoft.SqlAzure.DatabaseCopy</Type>  
  <State>Normal</State>  
  <SelfLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/cjxrvozmbh/databases/dbtest1/databasecopies/dfd31d9d-ef22-43e8-9054-d86cd3804b58</SelfLink>  
  <ParentLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/cjxrvozmbh/databases/dbtest1</ParentLink>  
  <SourceServerName>cjxrvozmbh</SourceServerName>  
  <SourceDatabaseName>dbtest1</SourceDatabaseName>  
  <DestinationServerName>cjxrvozmbh</DestinationServerName>  
  <DestinationDatabaseName>dbtest2</DestinationDatabaseName>  
  <IsContinuous>False</IsContinuous>  
  <IsOfflineSecondary>False</IsOfflineSecondary>  
  <IsTerminationAllowed>False</IsTerminationAllowed>  
  <StartDate>2014-04-07T21:20:54.3970000Z</StartDate>  
  <ModifyDate>2014-04-07T21:20:54.3970000Z</ModifyDate>  
  <PercentComplete>0</PercentComplete>  
  <ReplicationState>0</ReplicationState>  
  <ReplicationStateDescription>PENDING</ReplicationStateDescription>  
  <LocalDatabaseId>5</LocalDatabaseId>  
  <IsLocalDatabaseReplicationTarget>False</IsLocalDatabaseReplicationTarget>  
  <IsInterlinkConnected>True</IsInterlinkConnected>  
</ServiceResource>  

For a description of the response body, see Get Database Copy (classic).

See Also

Azure SQL Database
Operations for Azure SQL Databases
Copying Databases in Azure SQL Database
Geo-Replication in Azure SQL Database