You can use statements in this topic to automatically delete expired backups, drop backup deletion strategies, and cancel backup deletion tasks. Both the sys tenant and user tenants support backup deletion operations.
For more information about data backup operations in OceanBase Database, see Backup and restore in Manage.
Syntax
Automatically delete expired backups
/* Set a backup deletion strategy for a specified tenant in the sys tenant. */
ALTER SYSTEM ADD DELETE BACKUP POLICY policy_name RECOVERY_WINDOW recovery_window TENANT tenant_name;
/* Set a backup deletion strategy for the current user tenant. */
ALTER SYSTEM ADD DELETE BACKUP POLICY policy_name RECOVERY_WINDOW recovery_window;
Drop a backup deletion strategy
/* Drop a backup deletion strategy for a specified tenant in the sys tenant. */
ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name TENANT tenant_name;
/* Drop a backup deletion strategy for the current user tenant. */
ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name;
Cancel a backup deletion task
/* Cancel the ongoing backup deletion task for a specified tenant in the sys tenant. If you do not specify the TENANT parameter, the ongoing backup deletion tasks of all user tenants are canceled. */
ALTER SYSTEM CANCEL DELETE BACKUP [TENANT tenant_name_list];
/* Cancel the ongoing backup deletion task for the current user tenant. */
ALTER SYSTEM CANCEL DELETE BACKUP;
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 | The time window in which backups are restorable. |
Examples
In the sys tenant, set the backup deletion strategy to
defaultand the time window in which backups are restorable to 7 days for theMySQLtenant.obclient> ALTER SYSTEM ADD DELETE BACKUP POLICY 'default' RECOVERY_WINDOW '7d' TENANT MySQL;In a user tenant, set the backup deletion strategy to
defaultand the time window in which backups are restorable to 7 days for the current tenant.obclient> ALTER SYSTEM ADD DELETE BACKUP POLICY 'default' RECOVERY_WINDOW '7d';In the sys tenant, drop the backup deletion strategy named
defaultfor theMySQLtenant.obclient> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT MySQL;In the sys tenant, cancel the ongoing backup deletion tasks for the
MySQLandOracletenants.obclient> ALTER SYSTEM CANCEL DELETE BACKUP TENANT MySQL, Oracle;