After a cleanup policy is created, you can delete the policy to stop automatic cleanup of expired backups or to change the cleanup policy.
Considerations and notes
When all cleanup policies under a tenant are deleted, the automatic cleanup feature for that tenant is effectively disabled.
Deleting a cleanup policy does not affect any cleanup tasks that are currently in progress. It only means that the next time the system schedules automatic cleanup, the deleted policy will not generate any new cleanup tasks.
Delete a cleanup policy for a specified user tenant
Log in to the cluster as the
rootuser in thesystenant.Execute the following statement to delete the cleanup policy.
ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name TENANT [=] tenant_name;Where:
policy_name: the name of the cleanup policy to be deleted. You can obtain this name from theCDB_OB_BACKUP_DELETE_POLICYview.tenant_name: the name of the user tenant. When deleting a cleanup policy in the system tenant, you must specify the name of the user tenant, and only one user tenant name can be specified.
Here are some examples:
Delete the cleanup policy for the
mysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT mysql001;Delete the cleanup policy for the
oracle001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'log_only' TENANT oracle001;
Confirm whether the cleanup policy has been deleted.
obclient(root@sys)[(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_POLICY WHERE tenant_id = 1002;If the query result shows no records for the specified tenant, it indicates that the cleanup policy has been successfully deleted.
Delete a cleanup strategy of the current user tenant
Log in to the database as a tenant administrator.
Note
The administrator of a MySQL-compatible tenant is the
rootuser, and the administrator of an Oracle-compatible tenant is theSYSuser.Execute the following statement to delete the cleanup strategy.
The statement is as follows:
ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name;Here,
policy_namespecifies the name of the cleanup strategy to be deleted. You can query theoceanbase.DBA_OB_BACKUP_DELETE_POLICYorSYS.DBA_OB_BACKUP_DELETE_POLICYview to obtain the cleanup strategy of the current tenant.Here is an example:
MySQL-compatible modeOracle-compatible modeDelete the cleanup strategy
defaultof the current tenant in MySQL-compatible mode.obclient(root@mysql001)[(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';Delete the cleanup strategy
log_onlyof the current tenant in Oracle-compatible mode.obclient(SYS@oracle001)[SYS]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'log_only';Check whether the cleanup strategy has been deleted.
You can query the
oceanbase.DBA_OB_BACKUP_DELETE_POLICYview in MySQL-compatible mode or theSYS.DBA_OB_BACKUP_DELETE_POLICYview in Oracle-compatible mode to check whether the cleanup strategy of the current tenant has been deleted.Here are some examples:
MySQL-compatible modeOracle-compatible modeIn MySQL-compatible mode, execute the following statement:
obclient(root@mysql001)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_BACKUP_DELETE_POLICY;In Oracle-compatible mode, execute the following statement:
obclient(SYS@oracle001)[SYS]> SELECT * FROM SYS.DBA_OB_BACKUP_DELETE_POLICY;If the query result does not contain the corresponding cleanup strategy, the cleanup strategy of the tenant has been deleted.
What to do next
After you delete the cleanup strategy, we recommend that you set a new cleanup strategy to avoid the disk space being filled up due to the failure to clean up backup files, which may affect the backup operation. For more information about how to set a cleanup strategy, see Automatically clean up expired backups.