Cloud Backup provides the application-consistent backup feature in collaboration with Cloud Assistant and the backup service. Restoring data from an application-consistent backup prevents log replay when you start applications, such as databases. This ensures that your applications start in a consistent state.
Prerequisites
The Elastic Compute Service (ECS) instance must run one of the following operating systems:
Windows: Windows Server 2019, Windows Server 2016, and Windows Server 2012.
Linux: CentOS 7.6 and later, Ubuntu 18.04 and later, and Alibaba Cloud Linux 2 (2.1903 LTS 64-bit).
All disks that are attached to the ECS instance must be enhanced SSDs (ESSDs), and the file systems must be EXT3, EXT4, XFS, or NTFS.
For information about the regions that support ECS instance backup, see Features available by region. Although ECS instance backup is supported in the SAU (Riyadh - Partner Region) region, application-consistent backup is not.
Application-consistent backup is not supported if you enable snapshot-consistent groups, back up multiple ECS instances in a batch, or if any disk attached to the ECS instance is not an ESSD.
Background information
By default, Cloud Backup works with the Alibaba Cloud snapshot service to create crash-consistent backups. If you enable the application-consistent backup feature when you create an instance backup, an application-consistent backup is created based on your configurations.
Application-consistent backups capture in-memory data and in-progress database transactions when the backup is created. This process ensures the consistency of application data and database transactions. Application-consistent backups prevent data corruption, data loss, and log replay when you start database applications. This ensures that your 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.
Log on to the Resource Access Management (RAM) console using your Alibaba Cloud account.
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 an example of how to create the AppSnapshotRoleName RAM role.

Create a custom policy for the application-consistent backup feature. For more information, see Create custom policies.

Create the AppSnapshotPolicy policy. This policy grants permissions to query backup information, create backups, configure tags, and query disk information. Use the following policy content.
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:DescribeSnapshot*", "ecs:CreateSnapshot*", "ecs:TagResources", "ecs:DescribeDisks" ], "Resource": [ "*" ], "Condition": {} } ] }Attach the custom policy (AppSnapshotPolicy) to the RAM role (AppSnapshotRoleName). For more information, see Grant permissions to a RAM role.

Attach the RAM role (AppSnapshotRoleName) to the destination instance. For more information, see Instance RAM roles.
Step 2: Enable the application-consistent backup feature
For Windows instances, application consistency is achieved using the Volume Shadow Copy Service (VSS).
For Linux instances, you must customize shell scripts (freeze and unfreeze scripts) based on the applications on the ECS instance to achieve application consistency.
Log on to the Cloud Backup console.
In the navigation pane on the left, choose .
In the top navigation bar, select a region.
In the upper-left corner, click Add ECS Backup.
In the Add ECS Backup dialog box, configure the following parameters.
Select the objects to back up and click Next.
ImportantSelect the ECS instances that you want to back up. By default, all disks are backed up. You can click All Disks to select specific disks in the Backup Object dialog box.
By default, the Protect All Disks switch is enabled to protect all existing disks and any new disks that are attached to the ECS instance. You can disable the Protect All Disks switch and select specific disks to protect.
You can create backups for up to 99 ECS instances at a time.
Cloud Backup automatically detects whether the disks and operating system of the selected ECS instance support application-consistent snapshot groups. If the instance is supported, Cloud Backup first attempts to create an application-consistent snapshot group. If the creation requirements for an application-consistent snapshot group are not met, it attempts to create a snapshot-consistent group. If the creation requirements for a snapshot-consistent group are also not met, Cloud Backup creates a crash-consistent backup for each disk.
Configure backup options and click OK.
Select Manual Backup or Associate Backup Policy to specify the backup method. The following tables describe the parameters.
Click Application Consistent Backup.
Enable application-consistent backup for a Windows instance
NoteIf you select Application Consistent Backup, ensure that Cloud Assistant Agent is installed on the ECS instance. In the Windows operating system, the Cloud Assistant Agent process is named
AliyunService. For more information, see Overview of Cloud Assistant.Enable application-consistent backup for a Linux instance
Prepare freeze and unfreeze scripts based on the applications on the ECS instance and upload the scripts to the instance.
Use FTP or Cloud Assistant to upload the freeze and unfreeze scripts to the ECS instance.
Application freeze script path: Ensure that only the root user has read, write, and execute permissions for the script (permission 700). Example command:
chmod 700 /tmp/prescript.sh. The script must be saved to `/tmp/prescript.sh`.Application unfreeze script path: Only the root user must have read, write, and execute permissions for the script (permission 700). For example, run the following command:
chmod 700 /tmp/postscript.sh. The script must be saved to the `/tmp/postscript.sh` path.
ImportantIf you select Application Consistent Backup and correctly configure the scripts, you will create an application-consistent backup.
If you select Application Consistent Backup but the scripts are not configured correctly, a file system-consistent backup is created instead.
Sample application-consistent scripts:
Download application-consistent scripts for MySQL.
After you download and deploy the scripts, you must set the MySQL database password in the scripts.
Download application-consistent scripts for Oracle.
After you download and deploy the scripts, you must set the Oracle database installation path in the scripts.
NoteAfter you select Application Consistent Backup, ensure that Cloud Assistant Agent is installed on the ECS instance. On a Linux operating system, the Cloud Assistant Agent process is named
aliyun.service. Run theps aux|grep aliyun.servicecommand to verify the installation. For more information, see Overview of Cloud Assistant.
Click OK.