The DELETE BACKUPSET/ARCHIVELOG_PIECE statement is used to clean up a specified data backup set or log archive piece.
Limitations and considerations
When you use the
DELETE BACKUPSETstatement to clean up a specified data backup set, note the following:The dependency relationship between data backups must not be violated. If a data backup is dependent on its associated incremental backups, the dependent data backup can only be deleted after all incremental backups that depend on it have been deleted.
If you need to specify multiple
backup_set_idfor cleanup, allbackup_set_idmust be under the same backup path. You cannot clean up data backups from multiple paths in a single command.For the current backup path, you must retain at least one latest full data backup that can be used for restoration. That is, you can delete other backup sets before the most recent full backup only after retaining a full backup available for restoration.
If the data backup set to be deleted is not in the currently used backup path, ensure that OceanBase AI Database has access permissions for that backup path.
When using the
DELETE ARCHIVELOG_PIECEstatement to clean up a specified log archive piece, note the following:You must clean up the log archive pieces in order.
When cleaning up pieces in the current archive path, ensure that the pieces to be cleaned do not depend on any data backup in the current data backup path.
If you need to specify multiple
piece_idfor cleanup, allpiece_idmust be under the same archive path. You cannot clean up log archive pieces from multiple paths in a single command.
Privilege requirements
It must be executed by the root user of the sys tenant (root@sys) or the administrator user of a user tenant (root user).
Syntax
ALTER SYSTEM DELETE delete_action [TENANT [=] tenant_name];
delete_action:
BACKUPSET backup_set_id[,backup_set_id,...]
| ARCHIVELOG_PIECE piece_id[,piece_id,...]
Parameters
Parameter |
Description |
|---|---|
| backup_set_id | Specifies the ID of the backup set to be deleted. You can query the CDB_OB_BACKUP_SET_FILES(System tenant) or DBA_OB_BACKUP_SET_FILES(For user tenants) Query to obtain. Multiple data backup sets can be specified in a single command. Different backup_set_id Separate multiple values with commas. Specify multiple backup_set_id During cleanup, all backup_set_id are all under the same backup path. You cannot clean up data backups from multiple paths in a single command. |
| piece_id | Specifies the ID of the log archive piece to be deleted. You can query this ID from the view CDB_OB_ARCHIVELOG_PIECE_FILES(System tenant) or DBA_OB_ARCHIVELOG_PIECE_FILES(Queued tenant) Query to obtain. Multiple pieces can be specified in a single command. When specifying multiple pieces at the same time, piece_id During cleanup, all piece_id All are under the same backup directory. You cannot clean up log archive pieces in multiple directories with a single command. |
| tenant_name | Optional. Specifies the user tenant name whose backups need to be cleaned up. This parameter is required only when the command is executed by the system tenant. |
Examples
System tenant
Purge the specified data backup set.
The system tenant deletes the data backup set with
backup_set_id3 for tenantmysql001.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 3 TENANT = mysql001;The system tenant simultaneously deletes three data backup sets with IDs 1, 2, and 4 for the
mysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 1,2,4 TENANT = mysql001;
Purge a specified log archive piece.
The system tenant deletes the log archive piece with
piece_id5 for tenantmysql001.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5 TENANT = mysql001;The system tenant simultaneously deletes four log archive pieces with IDs 6, 7, 8, and 9 for tenant
mysql001.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9 TENANT = mysql001;
User tenant
Purge a specified data backup set.
The user tenant deletes its own data backup set with
backup_set_idequal to 3.obclient> ALTER SYSTEM DELETE BACKUPSET 3;The user tenant simultaneously deletes four data backup sets with
backup_set_idbeing 1, 2, and 4.obclient> ALTER SYSTEM DELETE BACKUPSET 1,2,4;
Purge a specified log archive piece.
User tenant deletes the log archive piece with
piece_id5 for this tenant.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5;The user tenant simultaneously deletes four log archive pieces with
piece_id6, 7, 8, and 9 from the current tenant.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9;