Purpose
The ALTER SYSTEM RESTORE statement is used to restore data from a tenant backup.
Limitations and considerations
Physical restore in OceanBase Database supports restoring within the same cluster and across different clusters.
Before using the
ALTER SYSTEM RESTOREstatement for physical restore, please confirm the version of the backup data to be restored. OceanBase Database currently only supports restoring backup data from a lower version to the same version or a higher version, and does not support reverse restore between minor versions within the same version.Before using the
ALTER SYSTEM RESTOREstatement for physical restore, please ensure that the required resources for the tenant to be restored have been created. For specific operations on creating resources for the tenant to be restored, please refer to Preparation before restore.The tenant restored by the
ALTER SYSTEM RESTOREstatement is by default a standby tenant. If you want to activate the standby tenant as the primary tenant to provide services, you need to execute theALTER SYSTEM ACTIVATE STANDBYstatement. For more information about theALTER SYSTEM ACTIVATE STANDBYstatement, please refer to ACTIVATE STANDBY.
Privilege requirements
Only the root user of the sys tenant (root@sys) can execute the ALTER SYSTEM RESTORE statement.
Syntax
ALTER SYSTEM RESTORE dest_tenant_name FROM uri [ UNTIL {TIME='timestamp' | SCN=scn} ] WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION [=] 'description'];
restore_option:
pool_list=pool_name[&locality=locality][&primary_zone=zone_name][&concurrency=int_num][&kms_encrypt={true | false}]
Parameters
| Parameter | Description |
|---|---|
| dest_tenant_name | The name of the new tenant to be restored. |
| uri | The data backup path backup_data_dest and log archive path log_archive_dest set during backup. This value must include at least one data backup path and one log archive path, separated by commas (,).Currently, OceanBase Database supports the following archive destination media: NFS, Alibaba Cloud OSS, Azure Blob (supported from V4.2.5 BP6 in V4.2.5), AWS S3, and object storage compatible with the S3 protocol, such as Huawei OBS, Google GCS, and Tencent Cloud COS. For examples of |
| timestamp | The timestamp to restore to, including this timestamp point. The timestamp must be specified with an equals sign (=). timestamp only supports the YYYY-MM-DD HH24:MI:SS.FF format, and the fractional part (FF) can have 0 to 6 decimal places, allowing for microsecond precision. For more information about how to select timestamp and scn values during restore, please refer to Parameters related to physical restore. |
| scn | The SCN to restore to, including this scn point. The scn must be specified with an equals sign (=). |
| restore_option | Supports parameters such as pool_list, locality, primary_zone, concurrency, and kms_encrypt, separated by &. When specifying locality and primary_zone, it is recommended to keep them consistent with the source tenant. If they are inconsistent, load balancing operations may occur when the standby tenant is activated as the primary tenant, affecting performance.
|
| WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password' | Specifies the encrypted key backup information for the tenant. This option is required only when the source tenant is configured with transparent encryption. The parameters are as follows:
|
| description | Optional. The user-specified description. |
Examples
Restore the
mysqltenant from the NFS data backup path and NFS log archive path to the specified timestamp2022-06-01 00:00:00, specify the resource pool asrestore_pool, the replica locality asF@z1,F@z2,F@z3, and theprimary_zoneasz1.obclient [oceanbase]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL TIME='2022-06-01 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 NFS log archive path to the latest archive point, specify the resource pool asrestore_pool, and set the data recovery concurrencyconcurrencyto 50.obclient [oceanbase]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' WITH 'pool_list=restore_pool&concurrency=50';Restore the
mysqltenant from the NFS data backup path and NFS log archive path to the specified SCN, specify the resource pool asrestore_pool.obclient [oceanbase]> ALTER SYSTEM RESTORE mysql FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' UNTIL SCN=1658285759724047000 WITH 'pool_list=restore_pool';Restore the
mysqltenant from the OSS backup path and OSS log archive path to the specified timestamp2022-06-01 00:00:00, specify the resource pool asrestore_pool.obclient [oceanbase]> 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-01 00:00:00' WITH 'pool_list=restore_pool';Execute the
RESTOREcommand on the target cluster to create and restore a standby tenant using the tenant's backup and archive.obclient [oceanbase]> 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';