Hybrid Backup Recovery (HBR) provides the application-consistent backup feature based on Cloud Assistant and the backup service. The application-consistent backup feature helps prevent unexpected startup operations during data restore, for example, log restore operations at the startup of database applications. This way, all applications start in a consistent state.

Prerequisites

  • Make sure that a public IP address or an elastic IP address (EIP) is configured for your ECS instance. This way, the ECS instance allows access over the Internet.
  • Make sure that your ECS instance runs one of the following operating systems:
    • Windows: Windows Server 2019, Windows Server 2016, and Windows Server 2012.
    • Linux: CentOS 7.6 and later versions, Ubuntu 18.04 and later versions, and Alibaba Cloud Linux 2 (2.1903 LTS 64-bit).
  • Make sure that all disks that are attached to your ECS instance are ESSD disks and the type of the file systems is EXT3, EXT4, XFS, or NTFS.
  • Make sure that your ECS instance is created in the Singapore (Singapore) or China (Hong Kong) region.

Background information

By default, Hybrid Backup Recovery (HBR) creates crash-consistent backup files based on the Alibaba Cloud snapshot service. If you enable the application-consistent backup feature when you create a backup file for an ECS instance, HBR creates an application-consistent backup file based on your business requirements.

The application-consistent backup feature helps back up in-memory data and in-progress database transactions when backup files are being created. This way, the consistency between the application data and database transactions is ensured. The application-consistent backup feature helps prevent data corruption, data loss, and log restore operations at the startup of database applications from occurring. This way, all applications start in a consistent state.

Step 1: Configure a RAM role for the ECS instance

Before you enable the application-consistent backup feature, you must configure a RAM role for the ECS instance.

  1. Log on to the RAM console by using your Alibaba Cloud account.
  2. Create a RAM role for the application-consistent backup feature. For more information, see Create a RAM role for a trusted Alibaba Cloud service.
    The following figure shows how to create the AppSnapshotRoleName RAM role. RAM role for the application-consistent backup feature
  3. Create a policy for the application-consistent backup feature. For more information, see Create a custom policy.
    Snapshot policy
    Create the AppSnapshotPolicy policy, which grants the permissions to query snapshot details, create snapshots, configure tags, and query disk details. You can use the following policy:
    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ecs:DescribeSnapshot*",
                    "ecs:CreateSnapshot*",
                    "ecs:TagResources",
                    "ecs:DescribeDisks"
                ],
                "Resource": [
                    "*"
                ],
                "Condition": null
            }
        ]
    }
  4. Attach the AppSnapshotPolicy policy to the AppSnapshotRoleName RAM role. For more information, see Grant permissions to a RAM role.
    Attach a policy
  5. Bind the AppSnapshotRoleName RAM role to the ECS instance. For more information, see Bind an instance RAM role.

Step 2: Enable the application-consistent backup feature

For Windows ECS instances, you can use Volume Shadow Copy Service (VSS) to ensure application consistency.

For Linux ECS instances, you must configure shell scripts, including pre-freeze and post-thaw scripts, based on the applications on the instance to ensure application consistency.

  1. Log on to the HBR console.
  2. In the left-side navigation pane, choose Backup > ECS Server Backup.
  3. In the top navigation bar, select a region.
  4. In the upper-right corner of the page, click +Add ECS Instance.
  5. In the Create ECS Protection Plan dialog box, set the parameters as described in the following table.
    1. Select the ECS instance that you want to protect.
      Note If you want to protect all disks of the ECS instance, turn on Protect All Disks. If you turn on Protect All Disks, all subsequent disks that are attached to the ECS instance are also protected. If you want to protect only specific disks, turn off Protect All Disks.
    2. Configure a backup plan. The following table describes the parameters of a backup plan.
      You can create backup files for an ECS instance on at regular intervals based on a specified backup policy. You can also create only one backup file of the current point in time for the ECS instance.
      Parameter Description
      On Schedule If you turn on On Schedule, HBR creates backup jobs at regular intervals based on the backup policy.
      Plan Name This parameter is required only if you turn on On Schedule. The name of the backup plan. If you do not specify a value for this parameter, a random name is specified for the backup plan.
      Start Time This parameter is required only if you turn on On Schedule. The start time of the scheduled backup plan. The time is accurate to seconds.
      Backup Interval This parameter is required only if you turn on On Schedule. The interval at which HBR runs backup jobs. Unit: hours, days, or weeks.
      Retention Period The period of time for which HBR retains backup files. Valid values: 1 to 65536. Unit: days.
    3. Click Application Consistent Backup.
      • Enable the application-consistent backup feature for a Windows ECS instance
        Note After Application Consistent Backup is specified, make sure that a Cloud Assistant client is installed on a Windows ECS instance. In Windows, the name of a Cloud Assistant client process is AliyunService. For more information, see Overview.
      • Enable the application-consistent backup feature for a Linux ECS instance

        Write application pre-freeze and post-thaw scripts based on the applications on a Linux ECS instance and upload the scripts to the ECS instance.

        You can upload the application pre-freeze and post-thaw scripts to the ECS instance over FTP or Cloud Assistant.

        • Application pre-freeze script: Grant the read, write, or execute permissions on the script only to the root user. The script is saved as /tmp/prescript.sh.
        • Application post-thaw script: Grant the read, write, and execute permissions on the script only to the root user. The script is saved as /tmp/postscript.sh.
        Notice
        • If Application Consistent Backup is specified and the scripts are configured as expected, HBR creates application-consistent backup files.
        • If Application Consistent Backup is specified but no scripts are configured or the scripts are not configured as expected, HBR creates file system-consistent backup files.
        Sample scripts for the application-consistent feature:
        Note After Application Consistent Backup is specified, make sure that a Cloud Assistant client is installed on the ECS instance. In Linux, the name of a Cloud Assistant client process is aliyun.service. You can run the ps aux|grep aliyun.service command to check whether a Cloud Assistant client is installed. For more information, see Overview.
    4. Click OK.