You can use the ADD DELETE BACKUP POLICY and DROP DELETE BACKUP POLICY statements to respectively set and drop a cleanup strategy.
To enable automatic cleanup for a tenant, you can use the ADD DELETE BACKUP POLICY statement to set a cleanup strategy for the tenant. Then, an automatic cleanup job is triggered every hour.
If you only want to cancel an ongoing cleanup job, you can execute the CANCELE DELETE BACKUP statement. For more information about the CANCELE DELETE BACKUP statement, see CANCEL DELETE BACKUP. If you do not want a canceled cleanup job to be scheduled again, you must first execute the DROP DELETE BACKUP POLICY statement to drop the corresponding automatic cleanup strategy and then execute the CANCELE DELETE BACKUP statement to cancel the cleanup job.
Limitations and considerations
You can use the
ADD DELETE BACKUP POLICYstatement to set only a tenant-level automatic cleanup strategy, but not a cluster-level cleanup strategy.You can set or delete only one cleanup strategy for one tenant at a time.
If all cleanup strategies of a tenant are dropped after you use the
DROP DELETE BACKUP POLICYstatement to drop a cleanup strategy for the tenant, automatic cleanup is disabled for the tenant.After you use the
DROP DELETE BACKUP POLICYstatement to drop a cleanup strategy, the ongoing cleanup jobs are not affected, but no cleanup jobs will be generated for the dropped cleanup strategy when the system schedules automatic cleanup next time.
Required privileges
You must execute this statement as the root user of the sys tenant (namely root@sys) or as the administrator of a user tenant.
- The default administrator is the
rootuser in MySQL mode. - The default administrator is the
SYSuser in Oracle mode.
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 |
|---|---|
| tenant_name | The name of the tenant. |
| POLICY | The name of the backup deletion strategy. Currently, this parameter can be set to default only, which indicates that only backups in data_backup_dest and log_archive_dest are automatically deleted. |
| RECOVERY_WINDOW | Optional. The time window for restoring backup data. If you do not specify this parameter, the default restorable window is 0 days, which indicates that backup sets never expire and the system does not clean up backup data. For more information about this parameter, see Backup cleanup parameter. |
Examples
sys tenant
Set a cleanup strategy named
defaultfor themysql_tenanttenant from the sys tenant, and set the restorable window to 7 days.obclient [oceanbase]> ALTER SYSTEM ADD DELETE BACKUP POLICY = 'default' RECOVERY_WINDOW ='7d' TENANT = mysql_tenant;Execute the following statement to query the cleanup strategies configured for the tenant:
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 setDrop the
defaultcleanup strategy for themysql_tenanttenant from the sys tenant.obclient [oceanbase]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT mysql_tenant;
User tenant
Set a cleanup strategy named
defaultfor theoracle_tenanttenant from the current tenant, and set the restorable window to 7 days.obclient [SYS]> ALTER SYSTEM ADD DELETE BACKUP POLICY 'default' RECOVERY_WINDOW '7d';Execute the following statement to query the cleanup strategies configured for the current tenant:
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 setDrop the
defaultcleanup strategy for theoracle_tenanttenant from the current tenant.obclient [SYS]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';