• Cloud-Native Container ProductsCloud-Native Container Products
    • KubeSphere Enterprisehot
    • KubeSphere Virtualizationhot
    • KubeSphere Enterprise HCI
  • Cloud-Native ServiceCloud-Native Service
    • KubeSphere Backuphot
    • KubeSphere Litenew
    • KubeSphere Inspectornew
  • Public Cloud Container ServicePublic Cloud Container Service
    • KubeSphere on AWS
    • KubeSphere on DigitalOcean

Create a backup plan

Describes how to create a backup plan on the console.

This topic describes how to create a backup plan on the console.

Prerequisites

Create a backup plan

  1. Log in to the KubeSphere Cloud platform with your account.

  2. In the upper-right corner, hover your cursor over the username area and click Console from the drop-down list.

  3. In the navigation pane on the left, click Backup and Recovery > Backup Plans, and then click Create Backup Plan.

    common:NOTE

    You can also click Create under Backup Plans on the Overview page.

  4. On the Create Backup Plan page, set the following parameters.

    ParameterRequiredDescription
    NameYesUser-defined name of the backup plan. The name can contain only lowercase letters, numbers, and hyphens (-), and must start and end with a lowercase letter or number. The maximum length is 63 characters.
    Object Storage RepositoryYesSelect an existing object storage repository from the drop-down list.
    If you have not created any repository, click Create Repository to create one. After creation, click and select the repository created.
    Source ClusterYesSelect an existing Kubernetes cluster from the drop-down list.
    If a cluster in the list is dimmed with a notice of Cluster not ready., please check whether the pods in the qiming-backend namespace of that cluster are up and running.
    If you have not imported any cluster, click Import to import a Kubernetes cluster. After importing, click and select the cluster imported.
    Backup ResourcesYesIt includes the following options:
    • Source Namespace: Select an existing namespace of the source cluster from the drop-down list.
    • Resource Template: Create a resource template so that you can reuse settings of the backup plan. For more information, please refer to Create and manage resource templates.
    DescriptionNoUser-defined description of the backup plan.
    Backup TypeYesSelect a backup type for the backup plan:
    • Instant: Execute a backup job immediately when the backup plan is created.
    • Scheduled: Execute backup jobs according to the specified frequency. Available system time zones include: UTC and Current Time Zone. Available frequencies include: Hour, Day, Week, and Month.
    Retention (Days): Retention period of the backup plan. The backup plan and the data uploaded to the storage repository will be deleted after the specified retention period.
    VolumesNoSelect Back up volumes to specify whether to back up the data in the volumes. Available backup methods include:
    • Copy Volumes: Copy the data in volumes for backup.
    • Use CSI Snapshot: Use the CSI snapshot to back up volumes. To use this method, ensure the associated volume snapshot class exists in your Kubernetes cluster. For more information about how to create a volume snapshot class, see Create a volume snapshot class.
    • Retained Snapshots: Set the number of snapshots to retain. The default value is All. To save the storage space, you can set this parameter based on the volumes used during backup. Please note that if the value is too small, it is possible that some snapshots may be deleted and cannot be restored.
    • Export snapshot: To prevent data loss and ensure rapid service recovery, you are advised to select this option to export the CSI snapshot while backing up volumes. The retention period of the snapshot equals to that of the backup plan.

    The following table describes differences among the three volume backup methods. Please choose the one that best fits your needs.

    Backup MethodApplication ScenariosBackup Speed for Large Volumes of DataData Consistency
    Copy VolumesCSI snapshot not supported by the storage systemSlowPartially inconsistent
    Use CSI SnapshotSame cloud environment, cluster, and storage systemFastConsistent
    Use CSI Snapshot + Export snapshotAcross cloud environments, clusters, or storage systemsSlowConsistent
  5. After setting the parameters, click OK. The successfully created backup plan will appear in the list.

    common:NOTE

    • According to the specified backup type and frequency, the number of generated protected applications differs. For example, if you select Scheduled and set the backup job to be executed at 00:00 and 12:00 every day, then 2 protected applications will be generated every day.

    • To view the usage records of the protected applications of the backup plan, go to the Overview page and click Usage Records in Subscription.

View and create a volume snapshot class

If you select Use CSI Snapshot when creating a backup plan, you have to ensure the associated volume snapshot class exists in your Kubernetes cluster. To view or create a volume snapshot class, refer to the following steps.

View a volume snapshot class

If you already have a volume snapshot class, refer to the following steps:

  1. Run the following command to view the PVCs in the namespace to be backed up. In the output, you can see the storage class associated with each PVC.

    $ kubectl get pvc -n <namespace> NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE busybox-test-a Bound pvc-5f0e74b8-d8d0-4c68-a3f8-5cd125a4d45a 10Gi RWO csi-hostpath-a 24h
  2. Run the following command to view the information about a specified storage class. In the output, you can see the PROVISIONER associated with the storage class.

    $ kubectl get sc csi-hostpath-a NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE csi-hostpath-a hostpath.csi.k8s.io-a Delete Immediate true 24h

    common:NOTE

    Make sure you replace the csi-hostpath-a with the actual name of the storage class in your cluster.

  3. Run the following command to view the volume snapshot class. If any volume snapshot class exists in your cluster, you have to ensure that the PROVISIONER obtained in previous steps supports the existing volume snapshot class before making any snapshot of the PVCs. If no volume snapshot class exists in your cluster, perform the following steps to create one.

    $ kubectl get volumesnapshotclass --show-labels No resources found in tt namespace.

Create a volume snapshot class

If you want to create a volume snapshot class, refer to the following steps:

  1. Use the following content to create a YAML file, for example, volumesnapshotclass.yaml.

    apiVersion: snapshot.storage.k8s.io/v1 # Set this field according to the snapshot CRD version of your cluster. The service currently supports v1 and v1beta1. deletionPolicy: Retain # Must set to Retain. driver: hostpath.csi.k8s.io-a # Consistent with the PROVISIONER of the storage class in your cluster. kind: VolumeSnapshotClass metadata: name: csi-hostpath-sc # Set to any value accepted by Kubernetes. labels: velero.io/csi-volumesnapshot-class: 'true' # Must set this label. parameters: # (Optional) set this field according to your actual storage system. ...
  2. Run the following command to create the volume snapshot class.

    kubectl apply -f volumesnapshotclass.yaml
  3. Run the following command to view the volume snapshot class. Make sure the value of DRIVER in the output is consistent with the value of PROVISIONER associated with the storage class.

    $ kubectl get volumesnapshotclass --show-labels NAME DRIVER DELETIONPOLICY AGE LABELS csi-hostpath-sc hostpath.csi.k8s.io-a Retain 9s velero.io/csi-volumesnapshot-class=true

Notes

When using a volume snapshot class, you have to note that:

  • If PVCs created by CSI and other PVCs not created by CSI both exist in the namespace to be backed up, select Copy Volumes to back up your PVCs.

  • If PVCs created by multiple CSI drivers exist in the namespace to be backed up, perform the above steps to create a corresponding volume snapshot class for each CSI driver.

  • If multiple volume snapshot classes exist for the same CSI driver, the service will randomly select a volume snapshot class for backup.

  • When creating a recovery plan, make sure the target cluster can access the volume snapshot backup.

Create and manage resource templates

Create a resource template

When creating a backup plan, you can create a resource template so that you can reuse it. To create a template, refer to the following steps.

  1. In the Backup Resources area on the Create Backup Plan page, click Resource Template > Create Resource Template.

  2. In the Create Resource Template dialog box that is displayed, set the template name.

    common:NOTE

    App Resources and Cluster Resources are supported. By default, App Resources is enabled. If you need to back up cluster-level resources or both namespace-level and cluster-level resources, enable Cluster Resources. Here, App Resources is used as an example.

  3. In the Select App area, specify one or more source namespaces to back up by name or label.

  4. In the Filter Resources area, filter application resources by Group and Resource, and click OK.

    common:NOTE

    • If you do not filter application resources, all resources in the namespace will be selected.
    • If you have enabled Cluster Resources, but do not filter cluster resources, no cluster-level resources will be selected.
  5. In the Create Resource Template area, select the created template from the drop-down list.

  6. To edit the template, click next to the template from the drop-down list. On the Edit Resource Template page, change the resource template information as needed, and click OK.

View and manage resource templates

To view and manage all backup resource templates, please refer to the following steps.

  1. On the Backup Plans tab, click Resource Templates.

  2. In the My Templates dialog box that is displayed, you can view all templates.

  3. Click a template. On the upper-right corner of the page, you can apply, edit, and delete the template.

    common:NOTE

    You can also click Create Template on the left side of the page to create a template.

KubeSphere ®️ © QingCloud Technologies 2022