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
systenant of the cluster as therootuser.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 you delete a cleanup policy in the sys tenant, you must specify the name of a user tenant, and only one user tenant name can be specified.
Example: delete the cleanup policy for the
mysql001tenant from the sys tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT mysql001;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 policy of the current user tenant
Log in to the database as a tenant administrator.
Note
The administrator user of a user tenant is the
rootuser.Execute the following statement to delete the cleanup policy.
The statement is as follows:
ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name;Here,
policy_namespecifies the name of the cleanup policy to be deleted. You can query theoceanbase.DBA_OB_BACKUP_DELETE_POLICYview to obtain the cleanup policy of the current tenant.Here is an example:
Delete the cleanup policy
defaultof the current tenant.obclient(root@mysql001)[(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';Check whether the cleanup policy has been deleted.
You can query the
oceanbase.DBA_OB_BACKUP_DELETE_POLICYview to check whether the cleanup policy of the current tenant has been deleted.Sample query:
obclient(root@mysql001)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_BACKUP_DELETE_POLICY;If the query result does not contain the corresponding cleanup policy, the cleanup policy of the tenant has been deleted.
What to do next
After you delete the cleanup policy, we recommend that you set a new cleanup policy 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 policy, see Automatically clean up expired backups.