You can manually clear backup data as needed.
You can run the ALTER SYSTEM command to delete the specified backup_set_id, backup_piece_id, and backup_round_id, or clear expired data.
Preparations
Before you manually clear the expired backup data, you must specify the expiration time and clearing policy of backup data by setting recovery_window and auto_delete_obsolete_backup in the backup_dest_option configuration item.
Example:
obclient> ALTER SYSTEM SET backup_dest_option='log_archive_checkpoint_interval=5s&recovery_window=7d&auto_delete_obsolete_backup=false&log_archive_piece_switch_interval=120s&backup_copies=2';
In the example:
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, you can manually clear it.
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 tofalse. 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).
Clear specified backups
Log on to the database as the root user of the sys tenant.
Query the
CDB_OB_BACKUP_SET_DETAILSandCDB_OB_BACKUP_PIECE_FILESviews to find thebackup_set_id,piece_id, andround_idcorresponding to the backup data to be cleared.For more information about the fields in
CDB_OB_BACKUP_SET_DETAILSandCDB_OB_BACKUP_PIECE_FILES, see the "oceanbase.CDB_OB_BACKUP_SET_DETAILS" and "oceanbase.CDB_OB_BACKUP_PIECE_FILES" topics in Reference Guide (MySQL Mode).Select the command that is appropriate for your need to clear the backup data.
Clear backups with the specified
backup_set_idobclient> ALTER SYSTEM DELETE BACKUPSET backup_set_id;For example, you can run the following command to delete the backup whose
backup_set_idis1:obclient> ALTER SYSTEM DELETE BACKUPSET 1;When you run the
DELETE BACKUPSETcommand to clear the backups, the following constraints apply:If the
backup_destof thebackup_set_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, at least one complete and valid backup copy is retained. Otherwise, the constraint of retaining one valid backup copy does not apply.If the
backup_destof thebackup_set_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, the backup sets must be deleted in a specific order. For example, backup sets withbackup_set_idof1,2, and3must be deleted in the order of1first, followed by2, and3last. Otherwise, the constraint on the deletion order of backup sets does not apply.The command fails if the specified
backup_set_iddoes not exist, or the backup of the specifiedbackup_set_idis still ongoing.
Clear backups with the specified
piece_idobclient> ALTER SYSTEM DELETE BACKUPPIECE piece_id;When you run the
DELETE BACKUPPIECEcommand to clear the backups, the following constraints apply:You can only delete backup pieces in the Frozen or Inactive status.
If the
backup_destof thepiece_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, and the existing backups do not fully cover the backup piece, the correspondingpiece_idcannot be deleted. Otherwise, the correspondingpiece_idcan be deleted regardless of whether the existing backups fully cover the backup piece.If the
backup_destof thepiece_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, the backup pieces must be deleted in a specific order to prevent log discontinuity. For example, backup pieces withpiece_idof1,2, and3must be deleted in the order of1first, followed by2, and3last. Otherwise, the constraint on the deletion order of backup pieces does not apply.
Clear all data in a log backup round with the specified
round_idobclient> ALTER SYSTEM DELETE BACKUPROUND round_id;The constraints on the
DELETE BACKUPPIECEcommand also apply on theDELETE BACKUPROUNDcommand:You can only delete backup rounds in the Stop status.
If the
backup_destof theround_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, and the existing backups do not fully cover the backup round, the correspondinground_idcannot be deleted. Otherwise, the correspondinground_idcan be deleted regardless of whether the existing backups fully cover the backup round.If the
backup_destof theround_idto be deleted is the same as the destination specified in thebackup_destconfiguration item, the backup rounds must be deleted in a specific order to prevent log discontinuity. For example, backup rounds withround_idof1,2, and3must be deleted in the order of1first, followed by2, and3last. Otherwise, the constraint on the deletion order of backup rounds does not apply.
Clear expired backups
Log on to the database as the root user of the sys tenant.
Run the following command to clear expired backups:
obclient> ALTER SYSTEM DELETE OBSOLETE;The
DELETE OBSOLETEcommand has the following constraints:If no or only one valid backup set exists, the data of archived logs cannot be cleared if it is split into multiple backup pieces.
The
DELETE OBSOLETEcommand only deletes expired backups whose storage path is the same as the destination specified inbackup_dest. For more information about expired backups whose destination is changed, see "Clear specified backups" in this topic.The
DELETE OBSOLETEcommand does not delete secondary backups.The command fails if the number of existing backup copies is smaller than the value specified for
backup_copiesinbackup_dest_option.