Manually clear secondary backup data

2023-10-27 09:57:43  Updated

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_mode parameter in backup_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

  1. Log on to the sys tenant as the root user.

  2. Query the CDB_OB_BACKUP_SET_FILES and CDB_OB_BACKUP_PIECE_FILES views to find the backup_set_id, copy_id, and backup_piece_id corresponding to the secondary backup data to be cleared.

    • Obtain the backup_set_id and copy_id of the secondary backup data

      Sample statement for querying the CDB_OB_BACKUP_SET_FILES view:

      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 set
      

      Fields in query results:

      • BS_KEY: indicates the backup set ID corresponding to the data backup.``

      • COPY_ID: A value greater than 0 indicates 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_FILES view, see oceanbase.CDB_OB_BACKUP_SET_FILES.

    • Obtain the backup_piece_id and copy_id of the secondary log backup

      Sample statement for querying the oceanbase.CDB_OB_BACKUP_PIECE_FILES view:

      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 set
      

      Fields 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 than 0 indicates 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_FILES view, see oceanbase.CDB_OB_BACKUP_PIECE_FILES.

  3. Select the command that fits your needs to clear the secondary backup data.

    • Clear backup data with <backup_set_id,copy_id> specified

      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_interval in backup_dest_option is 0, logs other than the valid backup will be cleared. If the backup file is split into multiple backup pieces because the value of log_archive_piece_switch_interval in backup_dest_option is not 0, 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_id values. 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 corresponding backup set cannot be restored.

      Take note of the following constraints when you use the DELETE BACKUPSET statement to clear secondary backup data:

      • If the backup_dest of value the specified <backup_set_id,copy_id> value is the same as the destination specified in the backup_backup_dest parameter, at least one complete and valid backup copy is retained. Otherwise, all data will be cleared.

      • If the backup_dest value of the specified <backup_set_id,copy_id> value is the same as the destination specified in the backup_backup_dest parameter, 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> specified

      obclient> ALTER SYSTEM DELETE BACKUPPIECE backup_piece_id COPY copy_id;
      

      Take note of the following constraints when you use the DELETE BACKUPPIECE statement 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_dest value of the specified <backup_piece_id,copy_id> value is the same as the destination specified in the backup_backup_dest parameter, and the existing backups do not fully cover the backup_piece value, 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 the backup_piece value.

      • If the backup_dest value of the specified <backup_piece_id,copy_id> value is the same as the destination specified in the backup_backup_dest parameter, 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.

Contact Us