All Products
Search
Document Center

Database Backup:Restore an ApsaraDB RDS for MySQL instance in an emergency

Last Updated:Jan 29, 2024

Database Backup (DBS) provides the emergency recovery feature for ApsaraDB RDS for MySQL instances. This feature is developed based on copy data management (CDM). After you enable the sandbox feature of DBS, you can quickly create an emergency database instance as a sandbox instance. Read and write operations that are performed in each sandbox instance do not affect data in other sandbox instances or source databases. A sandbox instance can be used in scenarios such as disaster recovery drills, development and testing, query and analysis, and emergency recovery. This topic describes how to enable and use the emergency recovery feature.

Note

Prerequisites

  • The RDS instance meets the following requirements:

    • The RDS instance runs MySQL 8.0, MySQL 5.7, MySQL 5.6, or MySQL 5.5.

    • The RDS instance is of High-availability Edition.

    • The RDS instance uses local SSDs.

    • The RDS instance resides in one of the following regions: China (Hangzhou), China (Shanghai), China East 1 Finance, China (Shenzhen), China (Heyuan), China (Chengdu), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Hong Kong), Singapore, Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Japan (Tokyo), India (Mumbai), Germany (Frankfurt), US (Silicon Valley), and US (Virginia).

  • Note

    To view the information about your ApsaraDB RDS for MySQL instance, go to the Basic Information page of the instance.

  • At least one physical backup is complete for the ApsaraDB RDS for MySQL instance in the ApsaraDB RDS console. For more information, see Use the automatic backup feature or Manually back up an ApsaraDB RDS for MySQL instance.

  • Transparent Data Encryption (TDE) is disabled for the ApsaraDB RDS for MySQL instance. For more information, see Configure TDE.

  • PrivateLink is activated. For more information about how to activate PrivateLink in the console or by calling an operation, see Overview or OpenPrivateLinkService.

Feature description

Item

Description

Restoration range

The entire original ApsaraDB RDS for MySQL instance is recovered.

Point in time for data restoration

  • If the log backup feature is disabled, you can restore the data only to the point in time when the data is backed up.

  • If the log backup feature is enabled, you can restore the data to a point in time after the first full backup that is performed within the log backup retention period. For more information, see Use the log backup feature.

Billing

You are charged based on the following two billable items: sandbox storage and sandbox instance.

Billable item

Description

Sandbox storage

After you enable the sandbox feature, DBS automatically synchronizes the data to be backed up to the sandbox storage and generates snapshots for the data. DBS charges you for data storage based on the volume of the data that is stored in the sandbox storage. For more information, see the Sandbox storage fees section of the "DBS sandbox fees" topic.

Sandbox instance

After you create a sandbox instance, DBS charges you for sandbox instance resources based on the specifications and duration of the sandbox instance. If you do not create sandbox instances, you are not charged for sandbox instance resources. For more information, see the Sandbox instance fees section of the "DBS sandbox fees" topic.

Step 1: Enable the sandbox feature

Before you create an RDS instance as a sandbox instance and restore data to the sandbox instance, you must perform the following steps to enable the sandbox feature and configure a sandbox policy in the DBS console:

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Crash Recovery tab. On the tab that appears, click Enable DBS Sandbox.

  4. In the Set Sandbox Policy dialog box, configure the following parameters.

    Parameter

    Description

    Sandbox Feature

    Specifies whether to enable the sandbox feature. In this example, Sandbox Feature is turned on.

    Sandbox Data Retention Period

    The number of days for which DBS retains the data that is used to create sandbox instances. By default, DBS retains data in the last seven days. You can restore data to a point in time within the retention period. A longer retention period indicates larger storage space that is occupied.

    If you want to retain only the latest data snapshot, set this parameter to 0.

  5. Click OK.

    After you enable the sandbox feature, the value of the Sandbox instance time range parameter changes to Data preparing. If you enable the sandbox feature for a backup schedule for the first time, DBS stores the latest full backup set to the sandbox storage and generates a snapshot that can be used to create sandbox instances. DBS requires a specific period of time to copy data. The period of time varies based on the size of the backup data and may be 5 to 20 minutes.

    After a specific time range is displayed as the value of the Sandbox instance time range parameter, you can create a sandbox instance and restore data to the sandbox instance.

    image.png

    The following table describes the values of the Sandbox instance time range parameter.

    Sandbox status

    Description

    Sandbox feature disabled

    The value of the Sandbox instance time range parameter is Unopened.

    Preparation after you enable the sandbox feature

    The value of the Sandbox instance time range parameter changes to Data preparing.

    Preparation completed

    The value of the Sandbox instance time range parameter changes to the time range in which available backup sets are created.

    Note

    The time range is from the start time of the earliest backup to the end time of the latest backup.

Step 2: Restore data to the sandbox instance

To quickly restore data to a sandbox instance, you must create a sandbox instance by performing the following steps: Read and write operations that are performed in each sandbox instance do not affect data in other sandbox instances or source databases..

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the left-side navigation pane, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Crash Recovery tab. On the tab that appears, click Enable DBS Sandbox.

  4. Click Recover Sandbox Instance. In the dialog box that appears, configure the following parameters.

    Section

    Parameter

    Description

    Sandbox Instance Point in Time

    Sandbox Data Time Range

    The time range within which available backup sets are created. The available time range is from the point in time at which the first snapshot was created in the sandbox storage to the current point in time. The actual available time range may be shorter.

    Note

    Data can be restored within the time range from the point in time at which the first snapshot was created in sandbox storage to the end time of the latest binary log file. Data may not be restored within the time range from the end time of the latest binary log file to the current point in time.

    You can view the point in time when the latest binary log file was generated on the Log Backup tab of the Base Backups tab on the Backup and Restoration page.

    Recovery Method

    • Recovery by Snapshot Point in Time: Recommended. You can select only the point in time at which a snapshot was created. This method takes less time to complete.

    • Recovery by Custom Point in Time: If the log backup feature is enabled, you can restore data to a specific point in time within the log backup retention period. The amount of time required for the restoration to complete varies based on the backup size. If the log backup feature is disabled, you can restore data only to the point in time at which a full backup set was created. For more information, see Use the log backup feature.

      Note

      You can specify a point in time to restore data only for an RDS instance of High-availability Edition that runs MySQL after you enable the log backup feature for the instance. For more information, see Use the log backup feature.

    Sandbox Instance Configurations

    Specifications

    The specifications of the sandbox instance that you want to create. Valid values:

    • 1 Core, 1 GB Memory

    • 1 Core, 2 GB Memory

    • 2 Cores, 4 GB Memory

    • 2 Cores, 8 GB Memory

    • 4 Cores, 8 GB Memory

    • 4 Cores, 16 GB Memory

    • 8 Cores, 16 GB Memory

    • 8 Cores, 32 GB Memory

    The restoration speed does not vary with the specifications of sandbox instances. However, sandbox instances with higher specifications deliver better performance. For more information, see the Sandbox instance fees section of the "DBS sandbox fees" topic.

    Region

    The region in which the sandbox instance resides. By default, the value of this parameter is fixed.

    Peer VPC

    The ID of the virtual private cloud (VPC) in which you want to deploy the sandbox instance.

    Note

    If you want to access the sandbox instance from an Elastic Compute Service (ECS) instance, you must set this parameter to the ID of the VPC in which the ECS instance is deployed. For more information about how to create a VPC, see Create and manage a VPC.

    Peer vSwitch

    The ID of the vSwitch in which you want to deploy the sandbox instance. The sandbox instance can be accessed from the CIDR blocks that are specified for the vSwitch.

    Security Group

    The security group that you want to use. You must select an advanced security group. Make sure that the security group allows traffic over port 3306. For more information, see Basic security groups and advanced security groups and Create a security group.

    Note

    This parameter is displayed only if you enable the emergency recovery feature for an instance for the first time.

    Database Account Type

    The type of the database account. Valid values:

    • Use Original Database Account: uses the account of the source database.

    • Create Privileged Account: creates a privileged account in the sandbox instance. The privileged account has permissions on all databases in the instance. You must enter a new Database Account and a Password. The account of the source database is retained in the sandbox instance.

      Note
      • A privileged account is created only in the current sandbox instance.

      • If the account name of the source database is the same as the name of the privileged account, the account of the source database is overwritten by the privileged account in the sandbox instance.

  5. Click OK.

    DBS performs a precheck and automatically creates the sandbox instance. After the state of the sandbox instance changes to Complete, you can access the sandbox instance.Sandbox Instance Status For more information, see Use DMS to access sandbox instances or Use ECS to access sandbox instances.

    The username and password of the account and all configurations of the sandbox instance are consistent with those of the source database. If you select Create Privileged Account in the preceding operation, you can also use the privileged account that is created to connect to the sandbox instance.

    Note

    The client that you use to connect to the sandbox instance must reside in the same VPC as the sandbox instance. For example, you can use an ECS instance to connect to the sandbox instance.

What to do next

Correct the online data on the original RDS instance

After the sandbox instance is created, you can use Data Transmission Service (DTS) to migrate data of some or all databases or tables to the original RDS instance to correct the online data of the original RDS instance. For more information, see Migrate data between ApsaraDB RDS for MySQL instances.

Note

When you create a migration task, specify the sandbox instance as the source database and the original RDS instance as the destination database, and set the Access Method parameter of the source database to Self-managed Database on ECS and the Access Method parameter of the destination database to Alibaba Cloud Instance.

Release a sandbox instance

If you no longer need the sandbox instance, you can release it based on your business requirements. After you release the sandbox instance, DBS no longer charges you for the sandbox storage. For more information, see the Billing section of this topic.

To release a sandbox instance, perform the following operations: In the left-side navigation pane of the instance details page, click Backup and Restoration. On the Crash Recovery tab of the page that appears, click Release Sandbox Instance in the Actions column of the sandbox instance.

Disable the emergency recovery feature

If your business does not require the emergency recovery feature, you can disable it. After the emergency recovery feature is disabled, existing sandbox instances are not affected.

To disable the emergency recovery feature, perform the following operations: In the left-side navigation pane of the instance details page, click Backup and Restoration. On the Crash Recovery tab, click Set Sandbox Policy. In the dialog box that appears, turn off Sandbox Feature.

Important

The emergency recovery feature described in this topic and the fast restoration feature for individual databases and tables provided by ApsaraDB RDS are developed based on the DBS sandbox feature. After you disable the emergency recovery feature, the usage and billing of the fast restoration feature for individual databases and tables are not affected. For more information, see Restore individual databases and tables.

image.png

Related API operations

Operation

Description

CreateSandboxInstance

Creates a sandbox instance.

DescribeSandboxInstances

Queries the sandbox instances that are created within an account.

DescribeSandboxRecoveryTime

Queries the recoverable time range of a sandbox instance.

DeleteSandboxInstance

Releases a sandbox instance.