The DELETE BACKUPSET/ARCHIVELOG_PIECE statement is used to clean up specified data backup sets or log archive pieces.
Limitations and considerations
When using the
DELETE BACKUPSETstatement to clean up specified data backup sets, the following considerations apply:Do not disrupt the dependencies between data backups. If a data backup is depended on by an incremental backup, the dependent data backup can only be deleted after all incremental backups that depend on it have been deleted.
If multiple
backup_set_idvalues are to be specified for cleanup, allbackup_set_idvalues must be in the same backup path. It is not supported to clean up data backups from multiple paths in a single command.For the currently used backup path, at least one latest and restorable full data backup must be retained. That is, a restorable full backup must be retained before deleting other backup sets prior to it.
If the data backup set to be deleted is not in the currently used backup path, ensure that OceanBase Database has access permissions for the corresponding backup path.
When using the
DELETE ARCHIVELOG_PIECEstatement to clean up specified log archive pieces, the following considerations apply:Log archive pieces must be cleaned up in order.
When cleaning up pieces in the current archive path, the cleaned-up piece must not be depended on by any data backup in the current data backup path.
If multiple
piece_idvalues are to be specified for cleanup, allpiece_idvalues must be in the same archive path. It is not supported to clean up log archive pieces from multiple paths in a single command.
Privilege requirements
The statement must be executed by the root user of the sys tenant (root@sys) or the administrator of each tenant. Specifically:
- In MySQL-compatible mode, the default administrator is the
rootuser. - In Oracle-compatible mode, the default administrator is the
SYSuser.
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 | The ID of the backup set to be deleted. You can query the CDB_OB_BACKUP_SET_FILES view (for the sys tenant) or the DBA_OB_BACKUP_SET_FILES view (for a user tenant) to obtain this ID. In a single command, you can specify multiple data backup sets. Different backup_set_id values are separated by commas. When specifying multiple backup_set_id values for cleanup, all backup_set_id values must be in the same backup path. It is not supported to clean up data backups from multiple paths in a single command. |
| piece_id | The ID of the log archive piece to be deleted. You can query the CDB_OB_ARCHIVELOG_PIECE_FILES view (for the sys tenant) or the DBA_OB_ARCHIVELOG_PIECE_FILES view (for a user tenant) to obtain this ID. In a single command, you can specify multiple pieces. When specifying multiple piece_id values for cleanup, all piece_id values must be in the same archive path. It is not supported to clean up log archive pieces from multiple paths in a single command. |
| tenant_name | The name of the user tenant for which the backup is to be cleaned up. This parameter is optional and must be specified only when executed by the sys tenant. |
Examples
For the sys tenant
Clean up specified data backup sets.
The sys tenant deletes the data backup set with
backup_set_id3 of themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 3 TENANT = mysql001;The sys tenant deletes three data backup sets with
backup_set_id1, 2, and 4 of themysql001tenant in a single command.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 1,2,4 TENANT = mysql001;
Clean up specified log archive pieces.
The sys tenant deletes the log archive piece with
piece_id5 of themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5 TENANT = mysql001;The sys tenant deletes four log archive pieces with
piece_id6, 7, 8, and 9 of themysql001tenant in a single command.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9 TENANT = mysql001;
For a user tenant
Clean up specified data backup sets.
The user tenant deletes the data backup set with
backup_set_id3.obclient> ALTER SYSTEM DELETE BACKUPSET 3;The user tenant deletes four data backup sets with
backup_set_id1, 2, 4, and 5 in a single command.obclient> ALTER SYSTEM DELETE BACKUPSET 1,2,4;
Clean up specified log archive pieces.
The user tenant deletes the log archive piece with
piece_id5.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5;The user tenant deletes four log archive pieces with
piece_id6, 7, 8, and 9 in a single command.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9;