All Products
Search
Document Center

Database Backup:Restore a self-managed MySQL database in an emergency

Last Updated:Feb 06, 2024

Database Backup (DBS) provides the emergency recovery feature for self-managed MySQL databases. This feature is developed based on copy data management (CDM). After you enable the DBS sandbox feature, you can quickly create an emergency database instance as a sandbox instance to make backup data available. Read and write operations performed on multiple sandbox instances do not affect each other or the source self-managed MySQL database. 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.

Background information

The DBS sandbox feature is integrated with the data deduplication feature and storage virtualization feature to help reduce storage costs and overall costs for data backup. The data deduplication feature and incremental data merge feature ensure that full backup data is available for the server. The storage virtualization feature provides replicas of full backup data for read and write operations without the need to copy data. For more information about the features, common scenarios, pricing, and limits of sandbox instances, see Overview.

You can refer to this topic to restore only self-managed MySQL databases that run MySQL 5.7 or 8.0 in an emergency. For information about how to restore ApsaraDB RDS for MySQL instances in an emergency, see Use the emergency recovery feature for an ApsaraDB RDS for MySQL instances.

To restore a self-managed MySQL database in an emergency, perform the following steps:

Prerequisites

  • The source self-managed MySQL database runs MySQL 5.7 or 8.0.

    Note

    For more information about how to add a data source to DBS, see Add a data source.

  • A backup schedule is created, and at least one full backup task is complete.

    Note

    When you create the backup schedule, select MySQL as the data source type and Physical Backup as the backup method. For more information, see Create a backup schedule.

  • The backup schedule is in the Running state.

  • A virtual private cloud (VPC) is created. The VPC is used to access the sandbox instance. For more information, see Create and manage a VPC.

Pricing

You are charged for two billable items that are described in the following table.

Billable item

Description

Sandbox storage

After you enable the DBS 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 DBS sandbox fees.

RDS instance

You are charged sandbox instance fees only if you restore data to the sandbox instance.

You are charged for the new RDS instance to which data is restored. The instance uses the pay-as-you-go billing method. The actual fees of an RDS instance prevails.

Step 1: Enable the DBS sandbox feature

Before you create a sandbox instance and restore the data of a self-managed MySQL database to the sandbox instance, you must enable the sandbox feature and configure a sandbox policy in the DBS console. To do so, perform the following steps:

  1. Log on to the Database Backup (DBS) console.

  2. In the left-side navigation pane, click Backup Schedules. In the top navigation bar, select a region.

  3. On the Backup Schedules page, click Manage in the Actions column corresponding to a backup schedule.
  4. On the Configure Task page, click Set Sandbox Feature in the Sandbox Information section.

    image.png

  5. In the Set Sandbox Policy dialog box, turn on Sandbox Feature and configure the Sandbox Data Retention Period parameter.

    image.png

    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 data. You can use the retained data to create sandbox instances. By default, DBS retains the data that is backed up in the previous seven days. 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.

  6. 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

Perform the following steps to create a sandbox instance. This way, if your self-managed MySQL database encounters disasters, you can quickly restore the database data to the sandbox instance. Read and write operations performed on multiple sandbox instances do not affect each other or the source self-managed MySQL database.

  1. Log on to the Database Backup (DBS) console.

  2. In the left-side navigation pane, click Backup Schedules. In the top navigation bar, select a region.

  3. On the Backup Schedules page, find the backup schedule for which you want to restore data and click Manage in the Actions column.

  4. On the Sandbox Instance Tasks page, click Restore Sandbox Instance.

  5. In the dialog box that appears, configure the following parameters.

    image.png

    Section

    Parameter

    Description

    Sandbox Instance Point in Time

    Sandbox Data Time Range

    The time range in 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.

    Recovery Method

    • Recovery by Snapshot Point in Time: 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 incremental log backup is enabled, you can restore data to a specific point in time within the time range that is specified for the Available Time Range to Recover parameter. The amount of time required for the restoration varies based on the size of the backup data. If incremental log backup is disabled, you can restore data only to the point in time at which a full backup set was created.

    Sandbox Instance Configurations

    Type of Sandbox Instance

    The type of the sandbox instance. By default, ApsaraDB RDS Instance is selected.

    Edition

    The edition of the sandbox instance. For more information, see Overview.

    Region

    The region in which you want to deploy the RDS instance. By default, the region in which the backup schedule resides is selected.

    Peer VPC

    The ID of the virtual private cloud (VPC) in which you want to deploy the RDS 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 RDS instance. The RDS instance can be accessed from the CIDR blocks that are specified for the vSwitch.

    Specifications

    The specifications of the sandbox instance. The specifications that are displayed in the console prevail.

  6. Click OK.

    DBS performs a precheck and automatically creates the configured sandbox instance for disaster recovery. After the state of the sandbox instance changes to Completed, click the endpoint in the Sandbox Instance Address column to go to the ApsaraDB RDS console to access the sandbox instance.

    image.png

Related operations

Disable the sandbox feature

Note
  • Before you disable the sandbox feature, release the running sandbox instance. To do so, perform the following operations: On the Sandbox Instance Tasks page, find the sandbox instance that you want to release and click Release Sandbox Instance in the Actions column.

    This operation only deletes the sandbox instance records in the DBS console. The associated sandbox instance is not deleted.

  • After you disable the sandbox feature, DBS does not charge you for the sandbox storage.

On the Sandbox Instance Tasks page, click Set Sandbox Policy in the Sandbox Information section. In the Set Sandbox Policy dialog box, turn off Sandbox Feature and click OK.

Release a sandbox instance

If you want to release a sandbox instance that is used for disaster recovery, go to the ApsaraDB RDS console to release the sandbox instance. For more information, see Release or unsubscribe from an ApsaraDB RDS for MySQL instance.

Related API operations

API

Description

CreateSandboxInstance

Creates a sandbox instance.

DescribeSandboxRecoveryTime

Queries the recoverable time range of a sandbox instance.

DescribeSandboxInstances

Queries a list of sandbox instances that are created in a backup schedule.

DeleteSandboxInstance

Releases a sandbox instance.