The ADD DELETE BACKUP POLICY statement and the DROP DELETE BACKUP POLICY statement are used to set and delete cleanup policies, respectively.
If you need to enable automatic cleanup for users, you can use the ADD DELETE BACKUP POLICY statement to set a cleanup policy for a tenant. Tenants with a cleanup policy set will trigger an automatic cleanup task every hour.
During the execution of a cleanup task, if you only want to cancel the currently executing cleanup task, you can execute the CANCEL DELETE BACKUP statement. For more information about the CANCEL DELETE BACKUP statement, see CANCEL DELETE BACKUP. If you want the canceled cleanup task to no longer be scheduled for execution, you need to first execute the DROP DELETE BACKUP POLICY statement to delete the automatic cleanup policy, and then execute the CANCEL DELETE BACKUP statement to cancel the currently executing cleanup task.
Usage restrictions and considerations
When using the
ADD DELETE BACKUP POLICYstatement to set a cleanup policy, only tenant-level automatic cleanup policies are supported. Cluster-level cleanup policies are not supported.Each command can set or delete only one cleanup policy for one tenant.
When using the
DROP DELETE BACKUP POLICYstatement to delete a tenant's cleanup policy, when all cleanup policies under the tenant are deleted, it is equivalent to disabling the automatic cleanup feature for that tenant.Using the
DROP DELETE BACKUP POLICYstatement to delete a cleanup policy does not affect the currently executing cleanup task. It only means that the next time the system performs automatic cleanup scheduling, the deleted cleanup policy will no longer generate cleanup tasks.
Privilege requirements
The operation must be performed by the root user of the sys tenant (root@sys) or the administrator user of each tenant. Specifically:
- The default administrator user in MySQL-compatible mode is the
rootuser. - The default administrator user in Oracle-compatible mode is the
SYSuser.
Syntax
ALTER SYSTEM delete_backup_action [ TENANT [=] tenant_name ];
delete_backup_action:
ADD DELETE BACKUP POLICY [=] policy_name [RECOVERY_WINDOW [=] recovery_window]
| DROP DELETE BACKUP POLICY [=] policy_name
Parameters
Parameter |
Description |
|---|---|
| POLICY | Specifies the cleanup policy name. Supported values:
|
| RECOVERY_WINDOW | Controls the time window for which backup data can be recovered. Optional. If this parameter is not explicitly specified, the default recovery window is 0 days, meaning that backup sets do not expire and the system does not perform cleanup. For detailed information about this parameter, see Parameters related to backup cleanup. |
| tenant_name | Specifies the tenant name. Optional. This parameter needs to be specified only when the operation is performed in the sys tenant. |
Examples
Sys tenant
The sys tenant sets the cleanup policy for the
mysql_tenanttenant todefault, with a recovery window of 7 days.obclient [oceanbase]> ALTER SYSTEM ADD DELETE BACKUP POLICY = 'default' RECOVERY_WINDOW ='7d' TENANT = mysql_tenant;After the setting is successful, you can query the cleanup policies set for the tenant through the following statement.
obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_POLICY WHERE TENANT_ID=1002;The query result is as follows:
+-----------+-------------+-----------------+ | TENANT_ID | POLICY_NAME | RECOVERY_WINDOW | +-----------+-------------+-----------------+ | 1002 | default | 7d | +-----------+-------------+-----------------+ 1 row in setThe sys tenant deletes the cleanup policy
defaultfor themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT mysql_tenant;
User tenant
The
oracle_tenanttenant sets its own cleanup policy todefault, with a recovery window of 7 days.obclient [SYS]> ALTER SYSTEM ADD DELETE BACKUP POLICY 'default' RECOVERY_WINDOW '7d';After the setting is successful, you can query the cleanup policies set for this tenant through the following statement.
obclient [SYS]> SELECT * FROM SYS.DBA_OB_BACKUP_DELETE_POLICY;The query result is as follows:
+-------------+-----------------+ | POLICY_NAME | RECOVERY_WINDOW | +-------------+-----------------+ | default | 7d | +-------------+-----------------+ 1 row in setThe
oracle_tenanttenant deletes its own cleanup policy.obclient [SYS]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';
