This topic describes how to enable PolarDB for MySQL to automatically create backups at specified intervals or manually create backups to prevent data loss. PolarDB for MySQL allows you to retain backups of a cluster when you delete the cluster.

Backup types

Backup type Enabled by default Retention period (days) Description
Level-1 backup (data backup) Yes 3~14
  • Level-1 backups are created based on Redirect-on-Write (ROW) snapshots. These snapshots are stored in a cluster that supports PolarDB distributed storage. The system does not replicate data when it saves a data block to a snapshot. When a data block is modified, the system saves one of the previous versions of the data block to a snapshot and creates a new data block that is redirected by the original data block. Therefore, you can create backups within a few seconds regardless of the size of your database storage.
  • The PolarDB backup and restoration features use multi-threading parallel processing and innovative technologies. This allows you to restore data from a backup set (snapshot) to a new cluster within 10 minutes.
  • The following figure shows the total physical storage of level-1 backups. The total physical storage of level-1 backups
Warning By default, the level-1 backup feature is enabled. To disable the feature, submit a ticket. However, after you disable this feature, you may bear some risks. For example, data loss may occur due to user errors.
Level-2 backup (data backup) No 30~7300
  • Level-2 backups are level-1 backups that are compressed and then stored in on-premises storage. Level-2 backups are slower to restore than level-1 backups. However, level-2 backups are more cost-effective than level-1 backups.
  • If you enable this feature, expired level-1 backups will be transferred to on-premises storage and stored as level-2 backups. The backups are transferred at a rate of approximately 150 MB/s.
Note If a level-1 backup expires before the previous one is transferred to a level-2 backup, the level-1 backup is deleted and is not transferred to a level-2 backup. For example, a PolarDB cluster creates level-1 backups at 01:00 every day and retains the backups for 24 hours. If the PolarDB cluster creates Level-1 Backup A at 01:00 on January 1 and creates Level-1 Backup B at 01:00 on January 2. Level-1 Backup A expires at 01:00 on January 2 and starts to be transferred to a level-2 backup. However, Level-1 Backup A stores a large amount of data, and the transfer task is not complete by 01:00 on January 3. In this case, Level-1 Backup B is deleted after it expires at 01:00 on January 3 and is not transferred to a level-2 backup.
Log backup Yes 3~7300
  • The log backup feature allows you to create backups by uploading real-time redo logs to Object Storage Service (OSS) in parallel. Based on a full backup (snapshot) and the redo logs, you can perform a point-in-time recovery (PITR) for a PolarDB cluster. Log backups can prevent data loss caused by user errors and ensure the security of data that is generated within a time period.
  • If you perform a PITR, you must consider the amount of time that is required to query redo logs. Redo logs are queried at a rate of 1 GB every 20 seconds to 1 GB every 70 seconds. The total restoration duration is the sum of the time required to restore backup sets and the time required to query redo logs.

Pricing

The backup and restoration features of PolarDB are free of charge. Only storage fees are charged. In PolarDB, fees are calculated based on the storage consumed by backups (data and logs) and the retention period of these backups.

Table 1. Pricing
Region Level-1 backup Level-2 backup Log backup
Mainland China USD 0.000464/GB/hour USD 0.0000325/GB/hour USD 0.0000325/GB/hour
China (Hong Kong) and regions outside China USD 0.000650/GB/hour USD 0.0000455/GB/hour USD 0.0000455/GB/hour

Billing methods

Backup type Free quota Billing method
Level-1 backup Database storage usage × 50%

You can view the database storage usage of a cluster on the Overview page in the console.

  • Storage fee per hour = (Total physical storage of level-1 backups - Free quota) × Unit price per hour
    • You are not charged if the physical storage of the level-1 backups does not exceed the free quota.
    • For more information about the unit price per hour, see Pricing.
    • You can view the physical storage of level-1 backups in the console, as shown in the following figure.Total physical storage of level-1 backups
      Note The physical storage of level-1 backups of a PolarDB cluster is the sum of the dedicated physical storage consumed by all level-1 backups, as shown in part ①. It is not the sum of the logical data sizes of all level-1 backups, as shown in part ②. The data of the PolarDB cluster and multiple level-1 backups (snapshots) can be stored in the same physical data block that is calculated only once in the bill. For more information, see FAQ about the backup feature.

    For example, if the total physical storage of level-1 backups is 700 GB and the database storage usage is 1,000 GB, the storage fee per hour is USD 0.0928.

    The fee is calculated based on the following formula: [700 GB - (1,000 GB × 50%)] × USD 0.000464/GB/hour = USD 0.0928/hour.

  • Use storage plans to deduct fees

    PolarDB allows you to use storage plans to deduct fees for the storage of level-1 backups that exceeds the free quota. You can use storage plans together with the pay-as-you-go billing method.

    You can use a purchased storage plan to deduct the used storage of all PolarDB clusters within your account. The remaining capacity of the storage plan will be automatically used to deduct the storage that exceeds the free quota for level-1 backups at a ratio of 1:1 until the storage plan is exhausted. In this case, every 1 GB of the storage plan can deduct 1 GB of level-1 backup storage.

    If the remaining capacity of the storage plan is insufficient to deduct the used storage of level-1 backups, the excess storage is charged on a pay-as-you-go basis. For more information, see Storage plans.

Level-2 backup None Storage fee per hour = Total physical storage of level-2 backups × Unit price per hour

For example, if the total physical storage of level-2 backups is 1,000 GB, the storage fee per hour is USD 0.0325.

The fee is calculated based on the following formula: 1,000 GB × USD 0.0000325/GB/hour = USD 0.0325/hour.

Log backup 100 GB Storage fee per hour = (Total physical storage of log backups - 100 GB) × Unit price per hour

For example, if the total physical storage of log backups is 1,000 GB, the storage fee per hour is USD 0.02925.

The fee is calculated based on the following formula: (1,000 GB - 100 GB) × USD 0.0000325/GB/hour = USD 0.02925/hour.

Backup methods

Backup method Description
Automatic system backup
  • By default, automatic backup is performed one time a day. You can configure the start time and backup cycle for the automatic backup. For more information, see Configure automatic backup.
  • Automatically created backup files cannot be deleted.
Note To prevent data loss, automatic backup must be performed at least two times a week.
Manual backup
  • You can manually back up data based on your business requirements. You can create up to three backups for a cluster. For more information, see Manually create a backup.
  • Manually created backup files can be deleted.
Backup method Description
Automatic system backup Standard backup
  • By default, automatic backup is performed one time a day. You can configure the start time and backup cycle for the automatic backup. For more information, see Configure automatic backup.
  • Automatically created backup files cannot be deleted.
Note To prevent data loss, automatic backup must be performed at least two times a week.
Enhanced backup PolarDB supports the enhanced backup feature. This feature shortens the backup cycle and increases the backup frequency to speed up data restoration.

PolarDB allows you to create backups every 2, 3, or 4 hours for the data that is generated within the last 24 hours.

After you enable enhanced backup, all backups are retained for 24 hours. Backups are automatically deleted when the retention period expires. However, the system permanently retains the first backup that is created after 00:00 every day.

For example, if you specify a backup frequency of every 4 hours at 08:00 on March 1, the system automatically creates the first backup within 4 hours from 08:00 to 12:00 on March 1. Then, the system continues to create a backup every 4 hours.

If the current time is 16:00 on March 4, the system retains the following backups:
  • The backups created within the last 24 hours (from 16:00 on March 3 to 16:00 on March 4).
  • The backups created between 0:00 and 4:00 on March 3.
  • The backups created between 0:00 and 4:00 on March 2.
  • The backups created between 8:00 and 12:00 on March 1.
1
Then, after 4 hours (at 20:00 on March 4), the system retains the following backups:
  • The backups created within the last 24 hours (from 20:00 on March 3 to 20:00 on March 4).
  • The backups created between 0:00 and 4:00 on March 3.
  • The backups created between 0:00 and 4:00 on March 2.
  • The backups created between 8:00 and 12:00 on March 1.
2
Manual backup
  • You can manually back up data based on your business requirements. You can create up to three backups for a cluster. For more information, see Manually create a backup.
  • Manually created backup files can be deleted.

Configure automatic backup

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster resides.
  3. Find the cluster, and then click the cluster ID.
  4. In the left-side navigation pane, choose Settings and Management > Backup and Restore.
  5. Click the Backup Settings tab.
  6. Click Edit on the right of Backup Settings. In the dialog box that appears, set the following parameters.
    Type Parameter Description
    Back up Data Backup Frequency You can select Standard Backup or Enhanced Backup.
    • Standard Backup: Set the backup cycle and start time of automatic backup.
      Note To prevent data loss, automatic backup must be performed at least two times a week.
    • Enhanced Backup: Set the backup frequency. You can select Last 24 Hours, Every 2 Hours, Last 24 Hours, Every 3 Hours, or Last 24 Hours, Every 4 Hours.
    Data Backup Retention Period Specify the retention period for level-1 backups and level-2 backups.
    • Level-1 backup: Set the retention period for level-1 backups.
      Note Level-1 backups are retained for 3 to 14 days.
    • Level-2 backup: Enable or disable the level-2 backup feature.
      Note By default, the level-2 backup feature is disabled.
    Log Backup Log Backups Retained For Specify the retention period for log backups.
    Note
    • Log backups are retained for 3 to 7,300 days.
    • To retain log backups permanently, select Retained Before Cluster Is Deleted. The retention period parameter becomes unavailable after you select this option.
    General When Cluster is Deleted Specify the backup retention policy that applies when you delete a cluster.
    • Permanently Retain All Backups: retains all backups after you delete a cluster.
    • Permanently Retain Last Automatic Backup: retains the latest backup after you delete a cluster.
    • Immediately Delete All Backups: does not retain backups after you delete a cluster.
    Note
    • If you select the Permanently Retain All Backups or Permanently Retain Last Automatic Backup policy, the system runs an automatic backup task to store all data when you delete a cluster.
    • After you delete a cluster, level-1 backups are automatically transferred to level-2 backups. You can go to the Cluster Recycle page to view stored backups. For more information, see Cluster recycle bin.
  7. After you complete the backup settings, click OK.

Manually create a backup

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster resides.
  3. Find the cluster, and then click the cluster ID.
  4. In the left-side navigation pane, choose Settings and Management > Backup and Restore.
  5. On the Backups tab, click Create Backup.
  6. In the Create Backup message, click OK.
    Note You can manually create up to three backups for a cluster.

Restore data

For more information, see Restore data.

FAQ

Related API operations

API Description
CreateBackup Creates a full backup for a specified PolarDB cluster.
DescribeBackups Queries the backup information about a specified PolarDB cluster.
DeleteBackup Deletes the backups of a specified PolarDB cluster.
DescribeBackupPolicy Queries the automatic backup policy of a specified PolarDB cluster.
ModifyBackupPolicy Modifies the automatic backup policy of a specified PolarDB cluster.