# Creating a Backup Policy

A backup policy can drive the system to automatically execute CSBS backup jobs at the specified interval. Periodic backups can be used to restore data quickly against data corruption or loss.

#### Context

- Automatic backup jobs require enabling the backup policy. The system automatically backs up ECSs associated with the backup policy and deletes expired backups.
- Each user can create a maximum of 32 backup policies.
- A maximum of 64 ECSs can be associated with a backup policy.

#### Procedure

1. Log in to the CSBS management console.

   1. Log in to the management console.
   2. Click in the upper left corner of the management console and select a region and a project.
   3. Under Storage > Cloud Server Backup Service.
2. On the Policies tab page, click Create Backup Policy. SeeFigure 1.

   Figure 1 Creating a backup policy
3. Set the backup policy parameters according to Table 1.

   Table 1 Parameter description
   Parameter | Description | Remarks
   --- | --- | ---
   Name | Backup policy name. It is a string of 1 to 255 characters that can contain only digits, letters, underscores (_), and hyphens (-). | backup_policy

   Status

   Whether to enable the backup policy.
   - Enabled:
   - Disabled:

   Only after the backup policy is enabled, the system automatically backs up ECSs associated with the backup policy and deletes expired backups.

   Execution Time

   Execution time of the backup policy in a day

   A maximum of 24 backup times can be set in a day. The backup interval must be one hour or more. If backup jobs are executed in two consecutive days, the interval between the execution times of the last backup of the former day and the first backup of the latter day must be one hour or more.

   00:00, 02:00

   It is recommended that backup jobs be executed during off-peak hours or when there are no services running.

   Backup Period

   Dates for executing the backup job.
   - Weekly

     Specifies on which days of each week the backup job will be executed. You can select multiple days.

   - Daily

     Specifies the interval (every 1 to 30 days) for executing the backup job.

   Every day

   If you select Daily, the first backup time is supposed to be in the day when the backup policy is created. If the creation time of the backup policy is later than the latest execution time, the initial backup will be performed in the next backup cycle.

   It is recommended that backup jobs be executed during off-peak hours or when there are no services running.

   Retention Rule

   Rule that specifies how backups will be retained.
   - Time Period

     You can choose to retain backups for one month, three months, six months, or one year, or for any desired number (1 to 99999) of days.

   - Backup Quantity

     Specifies the maximum allowed number of backups for a single ECS. The value ranges from 1 to 99999.

     You can also set long-term retention rules. Long-term retention rules can be effective together with quantity-based retention rules.

     - The value range for daily backup retention is 0 to 100.
     - The value range for weekly backup retention is 0 to 100.
     - The value range for monthly backup retention is 0 to 100.
     - The value range for yearly backup retention is 0 to 100.

     For example, if you select daily backup, the system retains the latest backup every day. Although the disk is backed up for multiple times in a day, only the last backup of the current day is retained. If you set the retention number to 5, the latest five daily backups are retained. If there are more than five backup files, the system automatically deletes the earliest backups. If the daily backup, weekly backup, monthly backup, and yearly backup are all configured, the union backups are selected for retention. The long-term retention rule and the backup quantity can be executed at the same time, not generating conflicts.

   - Permanent
     NOTE:
     - When the number of retained backups exceeds the preset value, the system automatically deletes the earliest backups. When the retention periods of retained backups exceed the preset value, the system automatically deletes all expired backups. By default, the system automatically clears data every other day. The deleted backup does not affect other backups for restoration.
     - This parameter applies only to backups automatically scheduled by a backup policy. Those backups generated by a manually executed backup policy are not affected by this parameter and are not automatically deleted. You can manually delete them from the backup list.
     - After a backup is used to create an image, the backup will not be counted as a retained backup and will not be deleted automatically.
     - A maximum of 10 backups are retained for failed periodic backup jobs. They are retained for one month and can be manually deleted.

   6 months

   More frequent backup intervals create more backups or retain backups for a longer time, protecting data with a higher level but occupying more storage space. Set an appropriate backup period as required.

4. Add tags to the backup.

   A tag is represented in the form of a key-value pair. Tags are used to identify, classify, and search for cloud resources.

   Tags added in a backup policy apply to all backups generated using the backup policy. These tags are used to filter and manage backup resources only. A backup policy can have a maximum of 10 tags.

   Table 2 describes parameters of a tag.

   Table 2 Parameter description
   Parameter | Description | Example Value
   --- | --- | ---

   Key

   Tag key. Each tag of a backup policy has a unique key. The key of a tag is user-definable or is selected from those of existing tags in TMS.

   The naming rule of a tag key is as follows:
   - It ranges from 1 to 36 Unicode characters.
   - It can contain only letters, digits, hyphens (-), and underscores (_).

   Key_0001

   Value

   Tag value. Tag values can be repetitive or null.

   The naming rule of a tag value is as follows:
   - It ranges from 0 to 43 Unicode characters.
   - It can contain only letters, digits, hyphens (-), and underscores (_).

   Value_0001

5. Click OK.
6. In the row of the backup policy, click Associate Server. See Figure 2.

   Figure 2 Associating servers
7. In the available server list, select the ECSs you want to associate. After ECSs are selected, they are added to the list of selected servers.

   - A maximum of 64 ECSs can be associated with a backup policy.
   - If a selected ECS has been associated with another backup policy, it will be disassociated from the original backup policy automatically and then associated with the new backup policy.
   - If EVS disks on an ECS have been associated with a VBS backup policy, disassociate them from the VBS backup policy. Otherwise, two backups are generated for each of the EVS disks.
   - CSBS supports backing up ECSs with shared EVS disks.
   - You can only select ECSs that are in the Running or Stopped state.
8. Click OK.

Parent topic: Backup Policies