You can manually clear secondary backup data as needed.
Preparations
Before you manually clear the expired secondary backup data, you must specify the expiration time and clearing policy of secondary backup data by setting recovery_window and auto_delete_obsolete_backup in the backup_backup_dest_option configuration item.
Example:
obclient> ALTER SYSTEM SET backup_backup_dest_option='recovery_window=14d&auto_delete_obsolete_backup=false';
In the example:
recovery_windowspecifies the retention period of secondary backup data.If you do not specify this parameter in the
backup_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 secondary backup data will never expire. We recommend that you usebackup_backup_dest_optionto specify the retention period of secondary backup data.When the secondary backup expires, you can manually clear it.
auto_delete_obsolete_backupspecifies whether to automatically delete expired secondary backup data.If you do not specify this parameter in the
backup_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_backup_dest_optionto specify whether to automatically clear expired backup data.
For more information about backup_backup_dest_option, see the "backup_backup_dest_option" topic in Reference Guide (MySQL Mode) or Reference Guide (Oracle Mode).
Clear the secondary backup of 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,copy_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 secondary backup data.
Clear backups with the specified
<backup_set_id,copy_id>obclient> ALTER SYSTEM DELETE BACKUPSET backup_set_id COPY copy_id;If the backup is not split into multiple backup pieces because the value of
log_archive_piece_switch_intervalinbackup_dest_optionis0, clog data other than the valid backup will be deleted. If the backup file is split into multiple backup pieces because the value oflog_archive_piece_switch_intervalinbackup_dest_optionis not0, the corresponding clog data will not be deleted. NoticeBoth full backups and incremental backups can be deleted by specifying their
backup_set_id. Therefore, you need to ensure data integrity when you manually delete backups. If the backup that an incremental backup depends on is deleted, the corresponding backup set cannot be restored.When you use the
DELETE BACKUPSETcommand to clear the secondary backups, the following constraints apply:If the
backup_destof the<backup_set_id,copy_id>to be deleted is the same as the destination specified in thebackup_backup_destconfiguration item, at least one complete and valid backup copy is retained. Otherwise, the constraint of retaining one valid secondary backup copy does not apply.If the
backup_destof the<backup_set_id,copy_id>to be deleted is the same as the destination specified in thebackup_backup_destconfiguration item, the<backup_set_id,copy_id>must be deleted in a specific order. Otherwise, the constraint on the deletion order of<backup_set_id,copy_id>does not apply.The command fails if the specified
<backup_set_id,copy_id>does not exist, or the backup of the specified<backup_set_id,copy_id>is still ongoing.
Clear archived data with the specified
<piece_id,copy_id>obclient> ALTER SYSTEM DELETE BACKUPPIECE piece_id COPY copy_id;When you use the
DELETE BACKUPPIECEcommand to clear the archived backup data, the following constraints apply:You can only delete
<piece_id,copy_id>in the Frozen or Inactive status.If the
backup_destof the<piece_id,copy_id>to be deleted is the same as the destination specified in thebackup_backup_destconfiguration item, and the existing backups do not fully cover the backup piece, the corresponding<piece_id,copy_id>cannot be deleted. Otherwise, the corresponding<piece_id,copy_id>can be deleted regardless of whether the existing backups fully cover the backup piece.If the
backup_destof the<piece_id,copy_id>to be deleted is the same as the destination specified in thebackup_backup_destconfiguration item, the<piece_id,copy_id>must be deleted in a specific order. Otherwise, the constraint on the deletion order of<piece_id,copy_id>does not apply.