Container Service for Kubernetes (ACK) allows you to back up and restore stateful applications deployed in an ACK cluster. This is an all-in-one solution to achieve crash consistency, application consistency, and cross-region disaster recovery for stateful applications in ACK clusters. This topic describes how to use the application backup feature in the console to back up applications, create snapshots, and restore applications.

Prerequisites

The application backup component is installed. For more information, see Enable cluster backup.

Limits

  • When you back up an application, the resources in the Deleting state are not backed up.
  • If you want to use the Hybrid Backup Recovery (HBR) service, Submit a ticket to apply to be added to the whitelist.
  • If you want to use snapshots of disk volumes, you must install the Container Storage Interface (CSI) plug-in of V1.1.0 or later. For more information about how to install the CSI plug-in, see Install and upgrade the CSI plug-in.
  • If you want to create snapshots of Apsara File Storage NAS (NAS) volumes, which means that you select alibabacloud-cnfs-nas in the Change StorageClass column of the related persistent volume claim (PVC) when you create a snapshot, you must first create a StorageClass. For more information, see Use CNFS to manage NAS file systems.

Billing

If you use disks, NAS file systems, HBR, or snapshots when you back up an application, you are billed based on the following rules:

Step 1: Create a backup vault

When you back up applications in an ACK cluster, the backup files are stored in an Object Storage Service (OSS) bucket. If no backup vault is available when you create a backup task, you must perform the operations in Step 1. You need to specify only one backup vault for each ACK cluster.
Note You need to create only one backup vault in the region where your cluster is deployed. ACK clusters that are deployed in the region can share the specified backup vault.
  1. Log on to the ACK console.
  2. In the left-side navigation pane of the ACK console, choose Multi-cluster > Backup Center.
  3. On the Backup Center page, click Create.
  4. In the Create panel, set the following parameters and click OK.
    Parameter Description
    Vault Name The name of the backup vault. The name can contain lowercase letters and digits.
    OSS Bucket Region The region where the OSS bucket that you want to use is deployed.
    OSS Bucket Name The name of the OSS bucket. If you use an ACK managed cluster, the name of the OSS bucket must start with cnfs-oss***. You can claim a bucket by using CNFS OSS.
    OSS Bucket Subdirectory The subdirectory of the OSS bucket. This parameter is optional.

Step 2: Create a backup task

  1. On the Backup Center page, select a cluster from the Cluster drop-down list.
  2. Click Create Backup Plan.
  3. In the Create Backup Plan panel of the Application Backup page, set the following parameters and click OK.
    创建备份计划
    Parameter Description
    Name The name of the backup task. This parameter is required.
    Backup Vaults Select the backup vault that you want to use. This parameter is required.
    Backup Namespaces You can select one or more namespaces. Applications in the selected namespaces are backed up. This parameter is required.
    Label Specify a label. Applications with the specified label are backed up.
    Excluded Namespaces You can select one or more namespaces that you want to exclude from the backup task. Applications in the excluded namespaces are not backed up.
    Specify Resources You can specify one or more Kubernetes resources, and separate them with commas (,), for example, deploy, configmap. Only the specified Kubernetes resources are backed up.
    Excluded Resources You can specify one or more Kubernetes resources that you want to exclude from the backup task, and separate them with commas (,), for example, pod, secret. The excluded resources are not backed up.
    Volume Backup Specify whether to enable volume backup. You can enable this feature to back up the application data stored in the relevant volume.

    If you select Volume Backup, this feature is enabled. If the application data is stored in disks, the data is backed up by creating volume snapshots. If the application data is not stored in disks, the data is backed up by using HBR.

    Validity Period Specify the retention period of backup files. Backup files cannot be restored after they expire.
    Backup Type You can select Back up Now or Scheduled Backup.

    If you select Scheduled Backup, you must specify a backup cycle. You can enter a cron expression to set a backup schedule. For more information about how to use cron expressions, see how-use-cron-linux.

    Note
    • The name of the backup task can contain only lowercase letters and digits, and cannot contain space characters.
    • You can select or exclude more than one namespace.
    • You can specify only one resource label in each backup task.
    • Volume snapshots are created by using the snapshot feature for Alibaba Cloud disks while HBR is a fully managed service that offers improved efficiency, security, and cost savings in backup and storage.
    • You can set a backup schedule by entering a cron expression or a backup interval.
    • After you enable scheduled backup, you can view the details about scheduled backups on the Backup Plans tab of the Application Backup page.
    On the Backups and Snapshots tab, if the status of the backup task is Completed, the backup is created.

Step 3: Create snapshots for volumes of CNFS types

If you enable Volume Backup and use storage other than disks to store data when you create a backup task, the HBR service is used to store the data. You can select to create disk snapshots or Container Network File System (CNFS) snapshots in the cluster where you want to restore the application.
Notice If you want to restore the application across clusters, you must perform the following operations in the cluster to which you want to restore the application.
  1. On the Application Backup page, click the Backups and Snapshots tab.
  2. Find the backup task that you created and click Create Snapshot in the Actions column.
  3. In the Create Snapshot dialog box, select the PVC that you want to convert and select the related storage type from the drop-down list in the Change StorageClass column. Then, click Create Snapshot.
    Note You need to select the PVC that you want to convert and select the related storage type from the drop-down list. Otherwise, the snapshot created cannot be restored.
    Create a snapshot
    NAS volumes (alibabacloud-cnfs-nas) and disk volumes (alicloud-disk) are supported.
    After the status of the related PVC changes to ConvertionCompleted, the snapshot is created, as shown in the following figure.Create a snapshot

Step 4: Restore the application and volume

Notice Before you restore the application data, make sure that you have created a snapshot of the volume that needs to be backed up.
  1. On the Application Backup page, click the Restore tab.
  2. On the Restore tab, click Create Restoration Task.
  3. In the Create Restoration Task panel, set the following parameters and click OK.
    Create a restoration task
    Parameter Description
    Name The name of the restoration task. The name can contain only lowercase letters and digits.
    Backup Vaults Select the backup vault where backup files are stored.
    Select Backup Select a backup file.
    Reset Namespace If you want to select backup files in other namespaces, click Add, select the namespace to which the backup files belong, and then specify the namespace to which the backup files are restored after the colon (:).
    Note The system does not overwrite existing resources in the cluster when it restores data. It restores only resources that do not exist in the cluster. Before you can restore an application to an earlier version, you must delete the existing resources of the application.
  4. In the lower-left corner of the panel, click OK.
  5. Verify that the related stateful or stateless application, volumes, and Services can be started and accessed as normal.
    1. In the left-side navigation pane of the details page of the cluster to which you want to restore the application, choose Workloads > Deployments.
    2. Find the application and click Details in the Actions column.
      On the Pods tab, verify that the application is in the Running state.
    3. In the left-side navigation pane of the details page, choose Volumes > Persistent Volume Claims.
      On the Persistent Volume Claims page, you can view the PVC that is restored.
    4. In the left-side navigation pane of the details page, choose Network > Services.
    5. On the Services page, click the external endpoint to check whether the Service can be accessed.