To prevent irreversible data loss caused by malicious or accidental operations, OceanBase AI Database provides the recycle bin feature, which supports the quick restore of tenant-level data. This topic describes how to restore a tenant from the recycle bin.
OceanBase AI Database supports restoring a tenant from the recycle bin by using the FLASHBACK TENANT statement.
Limitations
Since only the sys tenant can drop tenants, a dropped user tenant can be moved only to the recycle bin of the sys tenant. Only the sys tenant can perform tenant restore operations.
Procedure
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xx.xx -P2883 -uroot@sys#cluster -p**** -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> USE oceanbase;Execute the
SHOW RECYCLEBINstatement to view the objects in the recycle bin of the currentsystenant.obclient(root@sys)[oceanbase]> SHOW RECYCLEBIN;The returned result is as follows:
+-------------------------------------+---------------+--------+----------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +-------------------------------------+---------------+--------+----------------------------+ | __recycle_$_100017_1673367572701376 | mq_t1 | TENANT | 2023-01-11 00:23:36.317242 | +-------------------------------------+---------------+--------+----------------------------+ 1 row in setFor more information about recycle bin parameters, see recyclebin.
Execute the
FLASHBACK TENANTstatement to restore a tenant from the recycle bin.To restore the
mq_t1tenant, execute the following statement:obclient(root@sys)[oceanbase]> FLASHBACK TENANT mq_t1 TO BEFORE DROP;For more information about the
FLASHBACK TENANTstatement, see FLASHBACK.Verify the execution result in the
DBA_OB_TENANTSview and the recycle bin.obclient(root@sys)[oceanbase]> SHOW RECYCLEBIN; Empty setIf the query result is empty, check the
DBA_OB_TENANTSview again to confirm that the tenant has been restored.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, CREATE_TIME, MODIFY_TIME, PRIMARY_ZONE, LOCALITY, COMPATIBILITY_MODE, STATUS FROM DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';The returned result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | COMPATIBILITY_MODE | STATUS | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ | 1036 | mq_t1 | USER | 2023-01-11 00:23:36.317242 | 2023-05-18 15:49:12.857944 | zone1;zone2 | FULL{1}@zone1, FULL{1}@zone2 | MYSQL | NORMAL | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ 1 row in set
References
For more information about tenant dropping and the recycle bin, see: