You can use the ADD DELETE BACKUP POLICY statement to set a backup cleanup strategy and the DROP DELETE BACKUP POLICY statement to drop a backup cleanup strategy.
After you set a backup cleanup strategy for a tenant, the system will automatically trigger a backup cleanup job for the tenant on an hourly basis.
If you want to only cancel an ongoing backup cleanup job, you can execute the CANCEL DELETE BACKUP statement. For more information about the CANCEL DELETE BACKUP statement, see CANCEL DELETE BACKUP. If you want to cancel an ongoing backup cleanup job and make sure that it will not be scheduled again, you must execute the DROP DELETE BACKUP POLICY statement to drop the backup cleanup strategy and then execute the CANCEL DELETE BACKUP statement to cancel the job.
Limitations and considerations
You can set backup cleanup strategies for tenants but not clusters.
You can set or drop one backup cleanup strategy for one tenant at a time.
After you drop all backup cleanup strategies for a tenant, automatic backup cleanup is disabled for the tenant.
Dropping a backup cleanup strategy does not affect ongoing backup cleanup jobs. When the system schedules automatic backup cleanup the next time, no backup cleanup job will be generated for the dropped backup cleanup strategy.
Required privileges
Only the root user of the sys tenant (root@sys) or the administrator user of a user tenant can execute this statement.
- The default administrator user in MySQL mode is
root. - The default administrator user in Oracle mode is
SYS.
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 cleanup 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 | The time window for restoring backup data. This parameter is optional. If you do not specify this parameter, the default value 0 takes effect, indicating that the backup set will never expire and the system will not delete it. For more information about this parameter, see Backup cleanup parameter. |
Examples
systenantIn the
systenant, set a backup cleanup strategy nameddefaultwith a 7-day restore time window for themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM ADD DELETE BACKUP POLICY = 'default' RECOVERY_WINDOW ='7d' TENANT = mysql_tenant;Query the backup cleanup strategy 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 setIn the
systenant, drop the backup cleanup strategy nameddefaultfor themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT mysql_tenant;
User tenant
In the
oracle_tenanttenant, set a backup cleanup strategy nameddefaultwith a 7-day restore time window for the current tenant.obclient [SYS]> ALTER SYSTEM ADD DELETE BACKUP POLICY 'default' RECOVERY_WINDOW '7d';Query the backup cleanup strategy 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 setIn the
oracle_tenanttenant, drop the backup cleanup strategy nameddefaultfor the current tenant.obclient [SYS]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';