Database Backup (DBS) allows you to back up and restore Alibaba Cloud databases such as ApsaraDB RDS for MySQL, ApsaraDB RDS for SQL Server, and ApsaraDB RDS for PostgreSQL databases, self-managed databases hosted on Elastic Compute Service (ECS) instances, on-premises databases, and databases hosted on third-party cloud services. This topic describes how to use DBS to back up and restore ECS-hosted self-managed MySQL databases to meet disaster recovery and security requirements. DBS provides features such as real-time backup, quick restoration, geo-disaster recovery, and long-term archiving. DBS helps you eliminate the security risks that may arise from data loss, accidental deletion, data encryption, ransomware, and hacker attacks.

Scenarios

  • You forgot to back up your business data.
  • You want to use a cost-effective disaster recovery scheme for your ECS-hosted databases.
  • Your database encountered a hacker attack and was deleted. You want to restore the data to the status of yesterday.
  • The database server encountered a Trojan horse attack. A large amount of data was lost, and the service website cannot be accessed.
  • You deleted the data files of your database by mistake. As a result, you cannot start mysqld.
  • Your colleague replaced your online database with a test database. However, the online database has not been backed up.
Note For more information about the database engine versions and database objects that are supported by DBS, the granularity of backup and restoration in DBS, and the features that are supported by DBS for different types of databases, see Database engines and features.

Backup and restoration solutions

Usage of ECS instancesBackup and restoration solution
Act as database serversUse DBS backup schedules
Act as application serversUse ECS snapshots
Act as both database servers and application serversUse DBS backup schedules and ECS snapshots
Note For more information about how to activate the ECS Snapshot service, see Activate ECS Snapshot.

Features of DBS

FeatureDescription
Real-time backupDBS obtains transaction logs from the memory of a database in real time and supports a recovery point objective (RPO) accurate to seconds.
Quick restorationDBS allows you to restore the data of a single table. This greatly reduces the recovery time objective (RTO).
Restoration to a point in time accurate to secondsDBS allows you to restore a database to a point in time accurate to seconds. You can restore a database to the status of the last second instead of the status of yesterday.
Low storage costsDBS provides a data compression ratio up to 30% to reduce storage costs and automatically archives backup data to cost-effective storage services.
Backup sets available to be queriedDBS allows you to query the data of backup sets. You can directly execute SQL statements to query the data, without restoring the data to databases.
Remote backup and restorationDBS supports remote backup where the distance between the backup source and backup destination is more than 2,000 kilometers. After the data is backed up, you can use DBS to restore the data to a database in the current region or another region.
Handling of table name conflictsDBS allows you to manually rename a table if duplicate names exist when you run restore tasks. DBS can also automatically rename a table.
Quick restoration to ApsaraDB for RDS instancesDBS can automatically create an ApsaraDB for RDS instance with the appropriate specifications and storage space based on the metadata of a backup set.

Step 1: Create a backup schedule

Go to the DBS buy page to create a backup schedule. For more information, see Purchase a backup schedule.

Step 2: Configure the backup schedule

Prerequisites

A backup gateway is configured for the self-managed database for which you want to perform physical backups. For more information, see Add a backup gateway.

Procedure

  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 ID of the backup schedule that you want to configure and click Configure Backup Schedule in the Actions column.
  4. In the Configure Backup Source and Destination step of the Configure Backup Schedule wizard, configure the parameters of the backup source and destination and click Next.
    Table 1. Parameters
    SectionParameterDescription
    N/ASchedule Name

    The name of the backup schedule. DBS automatically generates a backup schedule name. We recommend that you set a descriptive name that is easy to identify. Backup schedule names do not need to be unique.

    Backup Source InformationBackup Mode

    The method that is used to back up data. The default value of this parameter is the backup method that you selected when you purchased the backup schedule. In this example, Logical Backup is selected.

    Database LocationThe location of the database that you want to back up. Select ECS-Hosted Database.
    Instance Region

    The region in which the ECS instance that hosts the database resides.

    ECS Instance ID

    The ID of the ECS instance on which the database that you want to back up is hosted.

    Port Number

    The port used to connect to the database that you want to back up.

    Database NameThe name of the database that you want to back up.
    Database Account

    The username of the account used to connect to the database that you want to back up. The account must have permissions to back up the database. For more information, see Account permissions.

    Password

    The password of the account that is used to connect to the database that you want to back up.

    After you enter the username and password of the database account, click Test Connection next to the password to check whether the information of the database that you want to back up is valid. If the specified parameters are valid, the Test Passed message is displayed. If the Test Failed message is displayed, click Check next to Test Failed. Modify the information about the instance that you want to back up based on the check results.

    Backup Destination InformationBackup Storage TypeThe type of storage that is used to store the backup data. Valid values:
    • DBS Storage (recommended): Backup data is stored in DBS without requiring you to create storage space. You are charged based on the volume of your data that is stored in DBS. For more information about the billing method, see Storage fees.

      To reduce storage costs, we recommend that you use subscription storage plans. For more information, see Use storage plans.

    • OSS For User: You must create a bucket in the Object Storage Service (OSS) console in advance. For more information, see Create buckets.
    Note In this example, DBS Storage (recommended) is selected. If you select OSS For User, you must configure the OSS Bucket Name parameter, and only the Standard storage class is supported.
    Storage EncryptionThe method that is used to encrypt the stored data. Valid values:
    • Encrypted: recommended. DBS uses AES-256 to encrypt the stored data. AES-256 is one of the advanced encryption standard ciphers.

      The server-side encryption feature is used in OSS. When you upload an object to OSS, OSS encrypts and stores the object. When you download the encrypted object from OSS, OSS decrypts the object and returns the decrypted object to you. For more information, see Server-side encryption.

    • Non-encrypted: The backup data is not encrypted.
    OSS Bucket Name

    The name of the Object Storage Service (OSS) bucket that you want to use to store data.

    This parameter is displayed only if you set the Backup Storage Type parameter to OSS For User.

  5. In the Edit Backup Objects step, find the database or table that you want to back up and add it to the Selected section. Then, click Next.
    Note
    • If you selected Logical Backup when you purchased a backup schedule, DBS allows you to back up a single table, a single database, multiple databases, or an entire database instance. By default, all the incremental data is backed up during incremental backup.
      • You can click Select All in the lower-left corner of the page to select all databases. The database objects that can be backed up vary based on the database type. For more information, see Database engines and features.
      • By default, a backup schedule cannot be used to back up a database that is created after the backup schedule is created. To back up the database, you can add the database to the backup schedule on the Edit Backup Objects page of the backup schedule. For more information, see Modify backup objects.
    • If you selected Physical Backup when you purchased a backup schedule, you must back up an entire database instance.
  6. In the Configure Backup Time step, configure the parameters that are described in the following table. Then, click Next in the lower-right corner of the page.
    ParameterDescription
    Full-scale Backup Frequency

    The frequency of the backup schedule. Select Periodic Backup or Single Backup based on your business requirements.

    Note In scenarios where incremental data needs to be restored, we recommend that you select Periodic Backup and perform a full backup at least once a week. Otherwise, a large number of binary logs must be replayed during restoration. This process is prone to errors and may result in a prolonged recovery time objective (RTO).
    Full Data Backup Recurrence

    The days of the week on which DBS runs the backup schedule. This parameter must be specified if the Full-scale Backup Frequency parameter is set to Periodic Backup. Select at least one day of the week.

    Start At

    The point in time when a backup starts. This parameter must be specified if the Full-scale Backup Frequency parameter is set to Periodic Backup. We recommend that you specify a point in time during off-peak hours. Example: 01:00.

    Note If a previous full data backup is not complete at the start time of the next backup, DBS skips the next backup.
    Incremental Backup

    Specifies whether to enable incremental backup. If you enable incremental backup, make sure that the binary logging feature is enabled for the database that you want to back up.

    Note
    • This parameter is displayed only if you set the Full-scale Backup Frequency parameter to Periodic Backup.
    • By default, the binary logging feature is enabled for an ApsaraDB RDS for MySQL instance. If you use a self-managed database, you must manually enable the binary logging feature.
    Maximum Concurrent Threads for Full Data Backup

    The maximum number of concurrent threads that are available for a full backup. You can configure this parameter to adjust the backup speed. For example, you can reduce the number of backup threads to minimize impacts on the database.

    The maximum number of actual concurrent threads varies based on backup schedule specifications. For more information, see How do I change the maximum backup speed?

    Backup network speed limit

    The limit on the network bandwidth. Unit: MB/s. You can set the limit based on your needs. Default value: 0, which indicates that the network bandwidth is unlimited.

    Note This parameter is displayed only if you set the Database Type parameter to MySQL.
  7. In the Edit Lifecycle step, configure the lifecycle for full backup data in the Configure Full Data Backup Lifecycle section.
    Note If you set the Incremental Backup parameter to Enable in Step 6, you must configure the lifecycle for incremental backup data.
  8. After the configurations are complete, click Precheck in the lower-right corner of the page.
  9. If the Precheck Passed message appears, click Start Task.
    Note When the state of the backup schedule changes to Running, the backup schedule takes effect.

What to do next