Description
The ALTER SYSTEM RESTORE statement restores the data backed up for a tenant.
Limitations and considerations
Physical restore in OceanBase Database supports restore within the same cluster or between different clusters.
Before you use the
ALTER SYSTEM RESTOREstatement for physical restore, make sure that you have confirmed the version of the backup data to be restored. OceanBase Database allows you to restore low-version backup data to the same version or a later version, but does not support reverse restore between minor versions of the same version.Before you use the
ALTER SYSTEM RESTOREstatement for physical restore, make sure that you have created the resources required for the tenant to be restored. For more information, see Prepare resources before restore.A tenant restored by using the
ALTER SYSTEM RESTOREstatement is a standby tenant by default. To use it as a primary tenant, you need to execute theALTER SYSTEM ACTIVATE STANDBYstatement. For more information about theALTER SYSTEM ACTIVATE STANDBYstatement, see 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 tenant to restore. |
| uri | The data backup path backup_data_dest and log archive path log_archive_dest specified when data is backed up. The value of this parameter contains at least one data backup path and one log archive path, with English commas (,) separating the paths. At present, OceanBase Database supports the following media as the destination for archiving data: Network File System (NFS), Alibaba Cloud Object Storage Service (OSS), and Tencent Cloud Object Storage (COS). |
| TIME='timestamp' | SCN=scn | The timestamp to which data is to be restored. Data at this timestamp is included in the restored data. When you specify the restore timestamp or SCN using the TIME or SCN keyword, you must use the = sign to connect the keyword and the value. If you do not specify the UNTIL clause, data is restored to the latest timestamp by default. The timestamp value must be in the YYYY-MM-DD HH24:MI:SS.FF format, accurate to nanoseconds. For more information about how to select the timestamp and scn values, see Physical restore parameters. |
| restore_option | Supports parameters such as pool_list, locality, primary_zone, concurrency, and kms_encrypt. These parameters are separated with &. When specifying locality and primary_zone, it is recommended that you maintain the same structure as the source tenant. If the structures are different, activating the restored tenant as the primary tenant may result in load balancing operations, affecting performance.
|
| WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password' | The key information for restoring an encrypted tenant. If transparent encryption is enabled for the source tenant, you must specify the key information for restoring the tenant. In this parameter:
|
| description | User-defined description. This parameter is optional. |
Examples
Restore the
mysqltenant to the specified timestamp2022-06-01 00:00:00from the NFS data backup path and NFS log archive path. 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 to the latest archive point from the NFS data backup path and NFS log archive path. Specify the resource pool asrestore_pool. Also, specify the concurrencyconcurrencyof 50 for data restore.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 to the specified SCN from the NFS data backup path and NFS log archive path. 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 to the specified timestamp2022-06-01 00:00:00from the OSS backup path and OSS log archive path. 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';Restore the
mysqltenant to the specified timestamp2022-06-01 00:00:00from the COS data backup path and COS log archive path. Specify the resource pool asrestore_pool.obclient [oceanbase]> 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-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 data.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';