Purpose
You can use the ALTER SYSTEM RESTORE statement to restore the data of a standby tenant.
Limitations and considerations
OceanBase Database supports a physical restore within a cluster or across clusters.
Before you use the
ALTER SYSTEM RESTOREstatement for a physical restore, you must confirm the version of the OceanBase database that hosts the backup data to be restored. For more information, see Preparations.Before you use the
ALTER SYSTEM RESTOREstatement for a physical restore, you must make sure that resources required for the tenant to be restored have been created. For more information, see Preparations.By default, a tenant restored by using the
ALTER SYSTEM RESTOREstatement is a standby tenant. To switch the standby tenant to the PRIMARY role to provide services, execute theALTER SYSTEM ACTIVATE STANDBYstatement. For more information about theALTER SYSTEM ACTIVATE STANDBYstatement, see ACTIVATE STANDBY.
Required privileges
You can execute the ALTER SYSTEM RESTORE statement only as the root user of the sys tenant (namely root@sys).
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&method=method_name
Parameters
| Parameter | Description |
|---|---|
| dest_tenant_name | The name of the tenant to be restored. |
| uri | The data backup path and log archive path, which are respectively specified by backup_data_dest and log_archive_dest during backup. The value must contain at least one data backup path and one log archive path that are separated with a comma (,). OceanBase Database allows you to use Network File System (NFS), Alibaba Cloud Object Storage Service (OSS), Tencent Cloud Object Storage (COS), Amazon Simple Storage Service (S3), and other object storage services that are compatible with the S3 protocol, such as Huawei Object Storage Service (OBS) and Google Cloud Storage (GCS), as the media of archive destinations. For more information about how to specify uri, see SET LOG_ARCHIVE_DEST or SET DATA_BACKUP_DEST. |
| TIME='timestamp' | SCN=scn | The inclusive timestamp or SCN up to which the table is restored. To restore to a specified TIME or SCN value, join the parameter name and value with an equal sign (=). By default, if you do not specify the UNTIL clause, the tenant is restored to the latest timestamp or SCN. The value of timestamp must be in the YYYY-MM-DD HH24:MI:SS.FF format, accurate to nanoseconds. For more information about how to specify a timestamp or SCN for restore, see Parameters related to physical restore. |
| restore_option | The restore options, including pool_list, locality, primary_zone, concurrency, and method. Separate the options with ampersands (&).
|
| WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password' | The key backup information of the tenant. You need to specify the key backup information for a tenant restore only when the tenant is configured with transparent encryption. The parameters are described as follows:
|
| description | Optional. The description. |
Examples
Restore the
mysqltenant from a data backup path and log archive path in NFS to the timestamp2022-06-01 00:00:00. Set the resource pool torestore_pool, replica locality toF@z1,F@z2,F@z3, andprimary_zonetoz1.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 a data backup path and log archive path in NFS to the latest archive checkpoint. Set the resource pool torestore_poolandconcurrencyto50.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 a data backup path and log archive path in NFS to the specified SCN. Set the resource pool torestore_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 a data backup path and log archive path in OSS to the timestamp2022-06-01 00:00:00. Set the resource pool torestore_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 from a data backup path and log archive path in COS to the timestamp2022-06-01 00:00:00. Set the resource pool torestore_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';Here,
appidindicates the AppID of your Tencent Cloud account.Execute the
RESTOREstatement on the target cluster to create and restore a standby tenant from backups and archives of the tenant.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';Restore the
mysqltenant from a data backup path and log archive path in S3 to the timestamp2024-01-15 00:00:00. Set the resource pool torestore_pool.obclient [oceanbase]> ALTER SYSTEM RESTORE mysql FROM 's3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=xxx&access_key=xxx&s3_region=xxx, s3://oceanbase-test-bucket/backup/archive?host=s3.<region>.amazonaws.com&access_id=xxx&access_key=xxx&s3_region=xxx' UNTIL TIME='2024-01-15 00:00:00' WITH 'pool_list=restore_pool';Here,
s3_regionindicates the region where the S3 bucket is deployed.