You can automatically clear backup data as needed.
Notes
Only data stored in the backup destination specified by
backup_destcan be automatically cleared. If the destination of a backup has been changed, it must be manually cleared upon expiration.Automatic data clearing will retain at least one valid backup copy. If an expired backup is the only valid copy, it will not be automatically cleared.
Enable automatic data clearing by using the backup_dest_option configuration item
Log on to the database as the root user of the sys tenant.
Run the following command to set the expiration time and clearing policy of backup data by using the
backup_dest_optionconfiguration item.The following example enables automatic clearing of data older than seven days.
obclient> ALTER SYSTEM SET backup_dest_option='log_archive_checkpoint_interval=2m&recovery_window=7d&auto_delete_obsolete_backup=true&log_archive_piece_switch_interval=120s&backup_copies=2';In the command:
log_archive_checkpoint_intervalspecifies the interval for log backup.If you do not specify this parameter in the
backup_dest_optionconfiguration item, the value of the cluster-level configuration itemlog_archive_checkpoint_intervalis used by default. If you do not specify eitherbackup_dest_optionorlog_archive_checkpoint_interval, the default value120sis used. We recommend that you usebackup_dest_optionto specify the interval for log backup.recovery_windowspecifies the retention period of backup data.If you do not specify this parameter in the
backup_dest_optionconfiguration item, the value of the cluster-level configuration itembackup_recovery_windowis used by default. If you do not specify eitherbackup_dest_optionorbackup_recovery_window, the default value0is used, indicating that backup data will never expire. We recommend that you usebackup_dest_optionto specify the retention period of backup data.When the backup expires, the system automatically clears it based on preset rules.
auto_delete_obsolete_backupspecifies whether to automatically delete expired backup data.If you do not specify this parameter in the
backup_dest_optionconfiguration item, the value of the cluster-level configuration itemauto_delete_expired_backupis used by default. If you do not specify eitherbackup_dest_optionorauto_delete_expired_backup, the default valuefalseis used, indicating that expired backup data will not be automatically deleted. In this case,auto_delete_obsolete_backupmust be set totrue. We recommend that you usebackup_dest_optionto specify whether to automatically clear expired backup data.log_archive_piece_switch_intervalspecifies whether to automatically split the content of the log file directory into multiple directories based on a specific interval. The default value is0, indicating that no splitting is performed. The valid value range is [1d,7d].backup_copiesspecifies how many copies of backup data must be retained for backup redundancy. The default value is1. If you have specifiedbackup_backup_dest, we recommend that you set backup_copies to2. The valid value range of backup_copies is [1,8].If you set
backup_copiesto1, the system deletes backup data without considering whether its secondary backup is successful. If you setbackup_copiesto2, the system will only automatically delete backup data inbackup_destafter its secondary backup has been saved tobackup_backup_dest.
For more information about
backup_dest_option, see the "backup_dest_option" topic in Reference Guide (MySQL Mode) or Reference Guide (Oracle Mode).
Enable automatic data clearing by using the auto_delete_expired_backup configuration item
The cluster-level configuration item auto_delete_expired_backup can also be used to enable automatic clearing. We recommend that you use backup_dest_option to enable automatic clearing.
Log on to the database as the root user of the sys tenant.
Run the following command to set the expiration time of backup data by using the
backup_recovery_windowconfiguration item.obclient>ALTER SYSTEM SET backup_recovery_window = <expiration time>;backup_recovery_windowspecifies the time window in which a backup can be restored. The default value is0, which indicates permanent retention. We recommend that you set this parameter to'7d'so that the backup will be retained for one week. When the backup expires, the system automatically clears it.Example:
obclient> ALTER SYSTEM SET backup_recovery_window = '7d';Run the following command to enable automatic clearing of backup data by using the
auto_delete_expired_backupconfiguration item.obclient> ALTER SYSTEM SET auto_delete_expired_backup = 'True';Note
If a
9044error is reported, the data clearing task is ongoing and you are not allowed to initiate another clearing task.