Procedure
Log on to the
systenant as therootuser.Execute the following statement to start a restore task:
obclient> ALTER SYSTEM RESTORE dest_tenant_name FROM source_tenant_name AT 'uri' UNTIL 'timestamp' WITH 'restore_option' PREVIEW;The following table describes the parameters.
Parameter Description dest_tenant_name The name of the destination tenant to which the data is to be restored. source_tenant_name The name of the source tenant for which the data is backed up. uri The value of backup_destspecified during backup.timestamp The restore timestamp, which must be later than or equal to START_TIMEin theCDB_OB_BACKUP_SET_DETAILSview of the earliest data backup, and earlier than or equal toMAX_NEXT_TIMEin theCDB_OB_BACKUP_ARCHIVELOG_SUMMARYview of the log backup.restore_option The restore options, including backup_cluster_name,backup_cluster_id,pool_list,locality,primary_zone, andkms_encrypt.backup_cluster_name: required. The name of the source cluster.backup_cluster_id: required. Same as the value ofcluster_idof the source cluster.pool_list: required. The resource pool of the tenant. Multiple resource pools must be separated with commas (,).locality: optional. The locality of replicas of the new tenant, which must match the zone information ofpool_listof the cluster where the new tenant is located. By default, the locality of the source tenant is used. If the value specified for this parameter does not match the zone information ofpool_listof the cluster where the new tenant is located, the system resets the locality to the default value. That is, the system sets an F replica for each zone based onzone_listof resource_pool.
For example, the locality of the source tenant is"F@z1,F@z2,F@z3", and the zone distribution of the cluster where the new tenant is located is"z1,z2,z3,z4", the locality of the source tenant is used as the locality of the new tenant. If the locality of the source tenant is"F@z1,F@z2,F@z3,F@z4,F@z5", and the zone distribution of the cluster where the new tenant is located is"z1,z2,z3", the locality of the new tenant covers all zones of this cluster. That is, the locality of the new tenant is"F@z1,F@z2,F@z3".primary_zone: optional. The preferred position of the leader of the new tenant, which must matchpool_listandlocality. That is, it must match the zone information and meet the constraint thatprimary_regionmust have at least two Paxos members. By default, the primary zone of the source tenant is used. If the value specified for this parameter does not matchpool_listorlocalityof the cluster where the new tenant is located, the system resetsprimary_zoneto the default value. That is, leaders are randomly distributed to the zones based onzone_listoflocality.
For example, if the locality of the source tenant is"F@z1,F@z2,F@z3", the primary zone isz1, and the zone distribution of the cluster where the new tenant is located is"z1,z2,z3,z4", the primary zone of the new tenant is alsoz1. If the locality of the source tenant is"F@z1,F@z2,F@z3,F@z4,F@z5", the primary zone isz1, and the zone distribution of the cluster where the new tenant is located is "z1,z2,z3", the locality of the new tenant is"F@z1,F@z2,F@z3"and the primary zone is"z1,z2,z3".kms_encrypt: optional. Specifies whether encryption information is required. If the value istrue,kms_encrypt_infois required for restore.
Example of restoring PREVIEW:
obclient> ALTER SYSTEM RESTORE restored_trade FROM trade AT 'file:///data/nfs/backup' until '2020-05-21 09:39:54.071670' with 'backup_cluster_name=ob20daily.backup&backup_cluster_id=1&pool_list=restore_pool' PREVIEW;Execute the
SHOW RESTORE PREVIEW;statement to obtain the paths of the data to be restored.obclient> SHOW RESTORE PREVIEW; +--------------+-----------+---------+------------------------------------------------------------------------------------------------------------+-------------+ | backup_type | backup_id | copy_id | backup_dest | file_status | +--------------+-----------+---------+------------------------------------------------------------------------------------------------------------+-------------+ | BACKUP_SET | 1 | 0 | file:///data/nfs/backup/1/incarnation_1/1002/data/backup_set_1_full_20211225 | AVAILABLE | | BACKUP_SET | 2 | 0 | file:///data/nfs/backup/1/incarnation_1/1002/data/backup_set_2_inc_20211225 | AVAILABLE | | BACKUP_SET | 1 | 1 | file:///data/nfs/backup_backup/1/incarnation_1/1002/data/backup_set_1_full_20211225 | AVAILABLE | | BACKUP_SET | 2 | 1 | file:///data/nfs/backup_backup/1/incarnation_1/1002/data/backup_set_2_inc_20211225 | AVAILABLE | | BACKUP_PIECE | 1 | 0 | file:///data/nfs/backup/1/incarnation_1/1002/clog/1_1_20211225 | AVAILABLE | | BACKUP_PIECE | 2 | 0 | file:///data/nfs/backup/1/incarnation_1/1002/clog/1_2_20211225 | AVAILABLE | | BACKUP_PIECE | 2 | 1 | file:///data/nfs/backup_backup/1/incarnation_1/1002/clog/1_2_20211225 | AVAILABLE | +--------------+-----------+---------+------------------------------------------------------------------------------------------------------------+-------------+Execute the
ADD RESTORE SOURCEstatement to load the paths of the data to be restored.Note
xxxindicates a path obtained in the previous step. You need to select only one of the paths for each backup set or piece.obclient> ALTER SYSTEM ADD RESTORE SOURCE 'xxx';If the input is invalid, execute the following statement to clear the input:
obclient> ALTER SYSTEM CLEAR RESTORE SOURCE;Execute the following statement to restore data:
obclient> ALTER SYSTEM RESTORE <$restore_tenant> FROM <$backup_tenant> UNTIL '<$restore_checkpoint>' WITH 'backup_cluster_name=$backup_cluster_name&backup_cluster_id=$backup_cluster_id&pool_list=$resource_pool_list&locality=$F@zone_list&primary_zone=$primary_zone_list';Notice
Unlike a general physical restore statement, the SQL statement to initiate a restore task based on multiple secondary backup destinations does not include the
at 'backup_dest'clause.$restore_tenant: the name of the restored tenant.$backup_tenant: the name of the tenant whose data was backed up.$restore_checkpoint: the upper limit timestamp of the restore task.
Example:
obclient> ALTER SYSTEM RESTORE test_restore_tenant FROM test_backup_tenant UNTIL '2020-05-21 09:39:54.071670' WITH 'backup_cluster_name=test_oceanbase&backup_cluster_id=1&pool_list=small_pool_2&locality=F@z1&primary_zone=z1';