Cloud Backup 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
Your Elastic Compute Service (ECS) instance runs one of the following operating systems:
Windows: Windows Server 2019, Windows Server 2016, and Windows Server 2012.
Linux: CentOS version 7.6 and later, Ubuntu version 18.04 and later, and Alibaba Cloud Linux version 2 (2.1903 LTS 64-bit).
All disks that are attached to your ECS instance are enhanced SSDs (ESSDs) and the file systems are ext3, ext4, XFS, or New Technology File System (NTFS).
ECS instance backup is available only in some regions. For more information, see Features available in each region. SAU (Riyadh - Partner Region) supports ECS instance backup but does not support application-consistent backup.
Application-consistent backup is not supported if you use a snapshot-consistent group, or back up multiple ECS instances at a time, or if some disks attached to your ECS instance are not ESSDs.
Background information
By default, Cloud Backup creates crash-consistent backup files based on the Alibaba Cloud snapshot service. If you enable the application-consistent backup feature when you back up an ECS instance, Cloud Backup creates an application-consistent backup file based on the actual scenario.
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. 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.
Log on to the Resource Access Management (RAM) console with 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 how to create the AppSnapshotRoleName RAM role.
Create a policy for the application-consistent backup feature. For more information, see Create custom policies.
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": {} } ] }
Attach the AppSnapshotPolicy policy to the AppSnapshotRoleName RAM role. For more information, see Grant permissions to a RAM role.
Attach the AppSnapshotRoleName RAM role to the ECS instance. For more information, see Use instance RAM roles to control access to resources.
Step 2: Enable the application-consistent backup feature
For Windows ECS instances, you can use Volume Shadow Copy Service (VSS) to implement application consistency.
For Linux ECS instances, you must configure shell scripts (pre-freeze and post-thaw scripts) based on the applications deployed on the instances to implement application consistency.
Log on to the Cloud Backup console.
In the left-side navigation pane, choose .
In the top navigation bar, select a region.
In the upper-right corner of the page, click Add ECS Backup.
In the Add ECS Backup panel, perform the following steps:
Specify the backup objects and click Next.
ImportantYou must select the ECS instances and disks that you want to back up. Protect All Disks is turned on by default. If you want to protect all disks of an ECS instance, turn on Protect All Disks. In this case, the disks that are later attached to the ECS instance are also protected. If you want to protect only specific disks, turn off Protect All Disks.
You can associate up to 99 ECS instances with a backup policy.
Cloud Backup automatically checks whether the selected ECS instances support snapshot-consistent groups. Cloud Backup automatically creates a snapshot-consistent group for the ECS instances that support snapshot-consistent groups. If an ECS instance does not support snapshot-consistent groups, Cloud Backup ensures only the crash consistency of disks. For more information, see Create a snapshot-consistent group.
Configure the backup settings and click OK.
You can select Manual Backup or Auto Backup. The following list describes the parameters.
Select Application Consistent Backup.
Enable the application-consistent backup feature for a Windows ECS instance
NoteIf you select Application Consistent Backup, you must install Cloud Assistant Agent on the ECS instance. In Windows, the process of Cloud Assistant Agent is named
AliyunService
. For more information, see Overview.Enable the application-consistent backup feature for a Linux ECS instance
Write the application pre-freeze and post-thaw scripts based on the applications deployed on the ECS instance and upload the scripts to the ECS instance.
You can use the FTP service or Cloud Assistant to upload the application pre-freeze and post-thaw scripts to the ECS instance.
Application pre-freeze scripts: Run the
chmod 700 /tmp/prescript.sh
command to grant the read, write, and execute permissions on the scripts only to the root user. /tmp/prescript.sh is the save path of the scripts.Application post-thaw scripts: Run the
chmod 700 /tmp/postscript.sh
command to grant the read, write, and execute permissions on the scripts only to the root user. /tmp/postscript.sh is the save path of the scripts.
ImportantIf Application Consistent Backup is selected and the scripts are configured as expected, Cloud Backup creates application-consistent backup files.
If Application Consistent Backup is selected but no scripts are configured or the scripts are not configured as expected, Cloud Backup creates file system-consistent backup files.
Sample scripts for the application-consistent feature:
Download the application-consistent scripts for MySQL.
After you download and deploy the scripts, you must specify the password of a MySQL database in the scripts.
Download the application-consistent scripts for Oracle.
After you download and deploy the scripts, you must specify the installation path of an Oracle database in the scripts.
NoteIf you select Application Consistent Backup, you must install Cloud Assistant Agent on the ECS instance. In Linux, the process of Cloud Assistant Agent is named
aliyun.service
. You can run theps aux|grep aliyun.service
command to check whether Cloud Assistant Agent is installed. For more information, see Overview.
Click OK.