Use the create reverse task feature

更新时间:
复制 MD 格式

The Create Reverse Task feature of Data Transmission Service (DTS) sends data back to a source database in disaster recovery or service switchover scenarios.

Prerequisites

Usage notes

  • You can create a reverse instance only for a synchronization instance between SQL Server databases, MySQL databases, or ApsaraDB for MongoDB instances. For the reverse instance, only Incremental Data Synchronization can be selected for Synchronization Types.

    Important

    If the original synchronization instance involves SQL Server or MySQL databases, this feature is supported only when the destination database is an ApsaraDB database instance.

  • The reverse instance does not synchronize data written directly to the destination database before the reverse instance is created.

  • After a reverse instance is created, a precheck runs immediately. If the precheck passes, DTS starts to capture incremental data, but the incremental data writing module does not run.

  • To prevent data inconsistency or instance failure, pause the original instance before you start the corresponding reverse instance.

  • You can create only one reverse instance for each synchronization instance. After the reverse instance starts, you cannot directly start the original instance.

  • You cannot create a reverse instance for a cross-region or cross-country synchronization instance.

  • The tables to be synchronized must have primary keys or UNIQUE constraints, and all fields in the constraints must be unique. Otherwise, duplicate data may occur.

  • Set the retention period of binary logs based on the estimated recovery time after an exception occurs in the production database.

  • If the original task uses a Serverless instance, the reverse task uses a pay-as-you-go instance with the micro specification. If the original task uses a subscription or pay-as-you-go instance, the reverse task uses the same billing method and specification as the original task by default.

  • If the original task is a cross-region synchronization task, switch to the source region of the forward task to view the reverse task in the synchronization task list.

  • You are charged for a reverse task even when it is paused.

  • The Status of a DTS task may show Retrying if an exception prevents a connection to the business database. This is expected behavior.

Procedure

Database disaster recovery scenario

  1. Create a forward synchronization task to synchronize data from the production database to the disaster recovery database based on your service requirements.

    Select specifications as needed. Set the Retry Time for Failed Connections parameter based on the estimated recovery time for your database. For more information about creating a forward synchronization task, see One-way synchronization between RDS MySQL instances, Synchronization between RDS SQL Server instances, Synchronize data from an ApsaraDB for MongoDB replica set instance to another replica set or sharded cluster instance, and Synchronize data from an ApsaraDB for MongoDB sharded cluster instance to an ApsaraDB for MongoDB replica set or sharded cluster instance.

  2. Wait until the forward synchronization task's Status is Running, and then create a reverse task.

    1. In the Data Synchronization Tasks list, locate your forward synchronization task.

    2. In the Actions column for the target instance, choose 更多设置 > Create Reverse Task.

    3. In the Note dialog box, click OK.

      Wait for the precheck of the reverse instance to complete, at which point the Status changes to Performing Initial Synchronization.

      Note
      • If Auto Refresh is disabled, you must manually click the 刷新 icon above the Actions column to update the Status of the synchronization instance.

      • If the precheck fails, click View Cause. Then, click View Details for the failed check item, fix the issue as prompted, and run the precheck again.

    4. After the reverse task is created, no further operations are required.

  3. If the production database cannot be connected due to an exception, perform the following steps to restore your service.

    1. Pause the original DTS task.

      1. On the Data Synchronization Tasks page, find the original DTS task.

      2. To the right of the task, choose 更多设置 > Pause Task.

      3. In the Note dialog box, click OK.

      4. In the Task Paused dialog box, click OK.

    2. Switch your services to the disaster recovery database.

    3. Start the reverse instance.

      1. On the Data Synchronization Tasks page, find the newly created reverse instance.

      2. In the Actions column for the target instance, choose 更多设置 > Start Reverse Task.

      3. In the Note dialog box, click OK.

  4. After the production database is restored, perform the following steps to switch your services back to the production database and resume the synchronization tasks.

    1. Switch your services back to the original production database.

    2. Wait until the reverse task has no latency, and then pause the reverse task.

      The reverse task synchronizes data written to the disaster recovery database back to the production database.

    3. After the reverse task is paused, you can start the original forward synchronization task.

Service switchover scenario

  1. Create a reverse synchronization task.

    1. In the Data Synchronization Tasks list, find the forward synchronization task (the original DTS task).

    2. In the Actions column for the target instance, choose 更多设置 > Create Reverse Task.

    3. In the Note dialog box, click OK.

      Wait for the precheck of the reverse instance to complete, at which point the Status changes to Performing Initial Synchronization.

      Note
      • If Auto Refresh is disabled, you must manually click the 刷新 icon above the Actions column to update the Status of the synchronization instance.

      • If the precheck fails, click View Cause. Then, click View Details for the failed check item, fix the issue as prompted, and run the precheck again.

    4. After the reverse synchronization task is created, no further operations are required.

  2. Wait until the Incremental Data Collection module is running with zero latency.

    You can click the ID of a reverse synchronization task. On the Task Management page, you can view the status and latency of the module in the Progress section.

  3. Stop writing business data.

    To prevent data loss, temporarily stop your services and ensure no new data is written to the database.

  4. Pause the original DTS task.

    1. On the Data Synchronization Tasks page, find the original DTS task.

    2. To the right of the task, choose 更多设置 > Pause Task.

    3. In the Note dialog box, click OK.

    4. In the Task Paused dialog box, click OK.

  5. Switch your services to the destination database of the forward synchronization task.

  6. Start the reverse instance.

    1. On the Data Synchronization Tasks page, find the newly created reverse instance.

    2. In the Actions column for the target instance, choose 更多设置 > Start Reverse Task.

    3. In the Note dialog box, click OK.

  7. You can end or release the forward synchronization task.

    For more information, see End a DTS task and Release a DTS task.

FAQ

  • How do I select specifications when I create a forward synchronization task?

    Select the smallest specification (micro). After creating the reverse task, you can upgrade the task specifications based on your service volume. For more information, see Upgrade the link specifications of a task.

  • What do I do if a DTS task is in the Failed state after the production database is restored?

    You can start the DTS task. For more information, see Start a DTS task.