Purpose
You can use this statement to restore the data backups of a tenant.
Note
- You can restore only data blocks, rather than clogs, from a snapshot backup at the tenant level.
- A restore from a snapshot backup at the tenant level can only be initiated by the root user in the sys tenant.
Syntax
alter_system_restore_stmt:
ALTER SYSTEM restore_action;
restore_action:
/* Restore to a specified timestamp */
RESTORE dest_tenant_name FROM uri UNTIL TIME='timestamp' WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
/* Restore to a system change number (SCN) */
RESTORE dest_tenant_name FROM uri UNTIL SCN=scn WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
/* Restore to the latest timestamp */
RESTORE dest_tenant_name FROM uri WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
/* Restore the required macroblock data from the corresponding full and incremental backups at the backup destination to the standby tenant and then pull and replay the transaction logs */
RESTORE tenant_name FROM restore_path UNTIL restore_checkpoint
WITH 'pool_list=<pool_name>&primary_zone=<zone_name>';
/* Cancel ongoing tenant restore */
CANCEL RESTORE dest_tenant_name;
Parameters
| Parameter | Description |
|---|---|
| dest_tenant_name | The name of the target tenant. |
| uri | The data backup path backup_data_dest and log archive path log_archive_dest specified during restore. The value must contain at least one data backup path and one log archive path that are separated with a comma (,). Currently, Network File System (NFS) paths, Alibaba Cloud Object Storage Service (OSS) paths, and Tencent Cloud Object Storage (COS) paths are supported. |
| timestamp | The timestamp to which data is restored. Join the parameter name and value with an equal sign (=). The timestamp must be in the YYYY-MM-DD HH24:MI:SS.FF format, accurate to nanoseconds. |
| scn | The SCN to which data is restored. Join the parameter name and value with an equal sign (=). |
| restore_option | The restore options, including pool_list, locality, primary_zone, and kms_encrypt. Separate the options with ampersands (&).
|
| WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password' | The key backup information of the encrypted tenant. You need to specify the key backup information for a tenant restore only when the tenant is configured with transparent encryption.
|
| description | The description. This parameter is optional. |
| tenant_name | The name of the standby tenant. |
| restore_path | The path of the backup destination. |
| restore_checkpoint | The point in time to restore to. |
| pool_list | The list of resource pools. |
| primary_zone | The primary cluster. |
Examples
Restore the
mysqltenant from the NFS data backup path and the NFS log archive path to the timestamp2022-06-1 00:00:00. Specify the resource pool asrestore_pool, the replica locality asF@z1,F@z2,F@z3, andprimary_zoneasz1.obclient> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL TIME='2022-06-1 00:00:00' WITH 'pool_list=restore_pool&locality=F@z1,F@z2,F@z3&primary_zone=z1';Restore the
mysqltenant from the NFS data backup path and the NFS log archive path to the latest archive timestamp. Specify the resource pool asrestore_pool.obclient> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the NFS data backup path and the NFS log archive path to the specified SCN. Specify the resource pool asrestore_pool.obclient> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL SCN='xxxxxxxx' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the OSS data backup path and OSS log archive path to the timestamp2022-06-1 00:00:00. Specify the resource pool asrestore_pool.obclient> ALTER SYSTEM RESTORE mysql FROM 'oss://oceanbase-test-bucket/backup/data/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx,oss://oceanbase-test-bucket/backup/archive/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx' UNTIL TIME='2022-06-1 00:00:00' WITH 'pool_list=restore_pool';Restore the
mysqltenant from the COS data backup path and COS log archive path to the timestamp2022-06-1 00:00:00. Specify the resource pool asrestore_pool.obclient> ALTER SYSTEM RESTORE mysql FROM 'cos://oceanbase-test-bucket/backup/data/?host=cos.ap-xxx.myqcloud.com&access_id=xxx&access_key=xxx&appid=xxx,cos://oceanbase-test-bucket/backup/archive/?host=cos.ap-xxx.myqcloud.com&access_id=xxx&access_key=xxx&appid=xxx' UNTIL TIME='2022-06-1 00:00:00' WITH 'pool_list=restore_pool';Execute the
RESTOREstatement on the target cluster to create and restore the standby tenant from backups and archives of the tenant.obclient> ALTER SYSTEM RESTORE restore_oracle_tenant FROM 'file:///data/nfs/backup//ob_backup_oracle_tenant/archive,file:///data/nfs/backup//ob_backup_oracle_tenant/data' UNTIL TIME='2022-11-11 15:04:23.825558' with 'pool_list=small_pool_2&primary_zone=z1'; Query OK, 0 rows affectedCancel ongoing restores for the
mysqltenant.obclient> ALTER SYSTEM CANCEL RESTORE mysql; Query OK, 0 rows affected