You can manually clear secondary backup data as needed.
The methods that you can use to manually clear secondary backup data for clusters and tenants are the same.
Considerations
The clearing of archived log data depends on secondary data backup. Before you clear archived log data, make sure that the corresponding secondary data backup file exists. If no corresponding secondary data backup file exists, you cannot clear the archived log data.
If the secondary backup destination is a network file system (NFS), the system directly deletes the secondary backup files that meet the requirements when the system clears secondary backup data. If the secondary backup destination is Object Storage Service (OSS), the method for clearing secondary backup data depends on the value of the
delete_modeparameter inbackup_backup_dest. For more information, see Preparations for secondary backup.
Preparations
Before you manually clear the expired secondary backup data, you must specify a clearing strategy for secondary backup data by setting the recovery_window parameter in backup_backup_dest_option.
The recovery_window parameter specifies the time window for restoring secondary backup data. The system determines whether secondary backup data has expired based on the value of this parameter. For example, the configuration recovery_window='7d' indicates that backup data within the last 7 days can be restored, and the backup data beyond this restore window is considered expired. For more information about the recovery_window parameter, see Automatically clear backup data for clusters.
For more information about the recovery_window parameter in backup_backup_dest_option, see Preparations for secondary backup.
For more information about backup_backup_dest_option, see backup_backup_dest_option.
Clear the secondary backup data of a specified backup
Log on to the
systenant as therootuser.Query the
CDB_OB_BACKUP_SET_FILESandCDB_OB_BACKUP_PIECE_FILESviews to find thebackup_set_id,copy_id, andbackup_piece_idcorresponding to the secondary backup data to be cleared.Obtain the
backup_set_idandcopy_idof the secondary backup dataSample statement for querying the
CDB_OB_BACKUP_SET_FILESview:obclient> SELECT * FROM oceanbase.CDB_OB_BACKUP_SET_FILES WHERE tenant_id=1 AND copy_id>0 AND file_status != 'DELETED'; +-------------+-----------+--------+---------+-------------+-----------------+---------+-------------+----------------------------+----------------------------+------------------+------+------------+------------+--------------+-------------------+-------------------+----------------------+---------------------------+--------------------+ | INCARNATION | TENANT_ID | BS_KEY | COPY_ID | BACKUP_TYPE | ENCRYPTION_MODE | STATUS | FILE_STATUS | START_TIME | COMPLETION_TIME | ELAPSED_SECONDES | KEEP | KEEP_UNTIL | COMPRESSED | OUTPUT_BYTES | OUTPUT_RATE_BYTES | COMPRESSION_RATIO | OUTPUT_BYTES_DISPLAY | OUTPUT_RATE_BYTES_DISPLAY | TIME_TAKEN_DISPLAY | +-------------+-----------+--------+---------+-------------+-----------------+---------+-------------+----------------------------+----------------------------+------------------+------+------------+------------+--------------+-------------------+-------------------+----------------------+---------------------------+--------------------+ | 1 | 1 | 3 | 1 | D | NONE | SUCCESS | AVAILABLE | 2022-10-28 14:57:42.054454 | 2022-10-28 14:57:49.421584 | 7 | NO | | NO | 0 | 0.0000 | NULL | 0.00MB | 0.00MB/S | 00:00:07.367130 | +-------------+-----------+--------+---------+-------------+-----------------+---------+-------------+----------------------------+----------------------------+------------------+------+------------+------------+--------------+-------------------+-------------------+----------------------+---------------------------+--------------------+ 1 row in setFields in query results:
BS_KEY: indicates the backup set ID corresponding to the data backup.``COPY_ID: A value greater than0indicates a secondary backup task. This view contains information about the backup and secondary backup tasks.
For more information about the fields in the
CDB_OB_BACKUP_SET_FILESview, see oceanbase.CDB_OB_BACKUP_SET_FILES.Obtain the
backup_piece_idandcopy_idof the secondary log backupSample statement for querying the
oceanbase.CDB_OB_BACKUP_PIECE_FILESview:obclient> SELECT * FROM oceanbase.CDB_OB_BACKUP_PIECE_FILES WHERE tenant_id=1 AND copy_id>0 AND status!='ACTIVE' AND file_status!='DELETED'; +-------------+-----------+----------+-----------------+---------+-------------+----------------------------+----------------------------+----------------------------+--------+-------------+------------+----------------+ | INCARNATION | TENANT_ID | ROUND_ID | BACKUP_PIECE_ID | COPY_ID | CREATE_DATE | START_TS | CHECKPOINT_TS | MAX_TS | STATUS | FILE_STATUS | COMPATIBLE | START_PIECE_ID | +-------------+-----------+----------+-----------------+---------+-------------+----------------------------+----------------------------+----------------------------+--------+-------------+------------+----------------+ | 1 | 1 | 1 | 0 | 1 | 20221024 | 2022-10-24 18:02:10.951125 | 2022-10-24 19:43:06.867056 | 2022-10-24 19:43:14.075099 | FROZEN | AVAILABLE | 1 | 0 | +-------------+-----------+----------+-----------------+---------+-------------+----------------------------+----------------------------+----------------------------+--------+-------------+------------+----------------+ 1 row in setFields in query results:
BACKUP_PIECE_ID: indicates the piece ID of the log backup. If log splitting is enabled,backup_piece_id> 0. If log splitting is disabled,backup_piece_id= 0.COPY_ID: A value greater than0indicates a secondary backup task. This view contains information about the backup and secondary backup tasks.
For more information about the fields in the
CDB_OB_BACKUP_PIECE_FILESview, see oceanbase.CDB_OB_BACKUP_PIECE_FILES.
Select the command that fits your needs to clear the secondary backup data.
Clear backup data with
<backup_set_id,copy_id>specifiedobclient> 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, logs other than the valid backup will be cleared. If the backup file is split into multiple backup pieces because the value oflog_archive_piece_switch_intervalinbackup_dest_optionis not0, the corresponding logs will not be cleared.Notice
If log splitting is enabled, you must clear the corresponding logs by specifying
<backup_piece_id,copy_id>.Data of full backups and incremental backups can be cleared by specifying their
backup_set_idvalues. Therefore, you must ensure data integrity when you manually clear backup data. If the data of a backup that an incremental backup depends on is cleared, the correspondingbackup setcannot be restored.
Take note of the following constraints when you use the
DELETE BACKUPSETstatement to clear secondary backup data:If the
backup_destof value the specified<backup_set_id,copy_id>value is the same as the destination specified in thebackup_backup_destparameter, at least one complete and valid backup copy is retained. Otherwise, all data will be cleared.If the
backup_destvalue of the specified<backup_set_id,copy_id>value is the same as the destination specified in thebackup_backup_destparameter, the data specified by<backup_set_id,copy_id>must be cleared in a specific order. Otherwise, the constraint on the clearing order of data specified by<backup_set_id,copy_id>does not apply.The statement fails if the specified
<backup_set_id,copy_id>value does not exist, or the backup task of the data specified by<backup_set_id,copy_id>is still in progress.
Clear archived data with
<backup_piece_id,copy_id>specifiedobclient> ALTER SYSTEM DELETE BACKUPPIECE backup_piece_id COPY copy_id;Take note of the following constraints when you use the
DELETE BACKUPPIECEstatement to clear archived backup data:You can only clear the data specified by
<backup_piece_id,copy_id>in the Frozen or Inactive state.If the
backup_destvalue of the specified<backup_piece_id,copy_id>value is the same as the destination specified in thebackup_backup_destparameter, and the existing backups do not fully cover thebackup_piecevalue, the data specified by<backup_piece_id,copy_id>cannot be cleared. Otherwise, the data specified by<piece_id,copy_id>can be cleared regardless of whether the existing backups fully cover thebackup_piecevalue.If the
backup_destvalue of the specified<backup_piece_id,copy_id>value is the same as the destination specified in thebackup_backup_destparameter, the data specified by<backup_piece_id,copy_id>must be cleared in a specific order. Otherwise, the constraint on the clearing order of data specified by<backup_piece_id,copy_id>does not apply.