After you move the backup sets and archivelog pieces of a tenant to other paths due to business needs, you can load them and then execute the RESTORE statement to restore the tenant.
Prerequisites
You have obtained the storage paths of the backup sets and archivelog pieces to be restored.
The backup sets and archivelog pieces to be restored belong to the same tenant. Currently, you can restore a new tenant only from the backup sets and archivelog pieces of the same tenant.
You have completed the preparations. For more information, see Preparations before restore.
Procedure
Log in to the
systenant of the cluster where the tenant to be restored resides as therootuser.(Optional) Execute the
ALTER SYSTEM RESTORE...PREVIEWstatement to specify the original data backup path and log archive path, as well as the time point to restore to.The syntax is as follows:
ALTER SYSTEM RESTORE FROM 'uri' UNTIL { TIME='timestamp' | SCN=scn } PREVIEW;The parameters are described as follows:
uri: Specifies the original data backup path and log archive path, which must be separated with a comma (,).TIME='timestamp' | SCN=scn: Specifies the timestamp or SCN to restore to. You must explicitly specify this parameter in the statement.
For more information about the parameters, see RESTORE PREVIEW.
Here are some examples:
Specify the original data backup path and log archive path, and specify the SCN to restore to as
1712650554000909004.obclient [oceanbase]> ALTER SYSTEM RESTORE FROM 's3://ob_backup/data?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***, s3://oceanbase-test-bucket/backup/archive?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***' UNTIL SCN = 1712650554000909004 PREVIEW;Specify the original data backup path and log archive path, and specify the timestamp to restore to as
2024-04-09 16:15:54.obclient [oceanbase]> ALTER SYSTEM RESTORE FROM 's3://ob_backup/data?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***, s3://oceanbase-test-bucket/backup/archive?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***' UNTIL TIME = '2024-04-09 16:15:54' PREVIEW;
(Optional) Execute the
SHOW RESTORE PREVIEWstatement to query the backup sets and archivelog pieces required to restore to the specified time point.Notice
You must wait until the execution of the
ALTER SYSTEM RESTORE...PREVIEWstatement succeeds before you execute theSHOW RESTORE PREVIEWstatement. Otherwise, the query result is not as expected.obclient [oceanbase]> SHOW RESTORE PREVIEW;A sample query result is as follows:
+--------------+-----------+--------------------------------------------------------------------------------+------------------------------------------------------------------------------+ | backup_type | backup_id | backup_dest | description | +--------------+-----------+--------------------------------------------------------------------------------+------------------------------------------------------------------------------+ | BACKUP_SET | 1 | s3://ob_backup/data/backup_set_1_full?host=obs.***.myhuaweicloud.com | | | BACKUP_PIECE | 1 | s3://ob_backup/archive/piece_d1002r1p1?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T155954, checkpoint_scn_display: 20240409T160154. | | BACKUP_PIECE | 2 | s3://ob_backup/archive/piece_d1002r1p2?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T160154, checkpoint_scn_display: 20240409T160353. | | BACKUP_PIECE | 3 | s3://ob_backup/archive/piece_d1002r1p3?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T160354, checkpoint_scn_display: 20240409T160553. | | BACKUP_PIECE | 4 | s3://ob_backup/archive/piece_d1002r1p4?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T160554, checkpoint_scn_display: 20240409T160754. | | BACKUP_PIECE | 5 | s3://ob_backup/archive/piece_d1002r1p5?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T160754, checkpoint_scn_display: 20240409T160953. | | BACKUP_PIECE | 6 | s3://ob_backup/archive/piece_d1002r1p6?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T160954, checkpoint_scn_display: 20240409T161154. | | BACKUP_PIECE | 7 | s3://ob_backup/archive/piece_d1002r1p7?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T161154, checkpoint_scn_display: 20240409T161354. | | BACKUP_PIECE | 8 | s3://ob_backup/archive/piece_d1002r1p8?host=obs.***.myhuaweicloud.com | start_scn_display: 20240409T161354, checkpoint_scn_display: 20240409T161554. | +--------------+-----------+--------------------------------------------------------------------------------+------------------------------------------------------------------------------+ 9 rows in setThe query result shows all the backup sets and archivelog pieces required to restore to the specified time point, as well as their storage paths in the original data backup and log archive destinations. If you have moved some or all of these files to other paths or storage media due to business needs, you must maintain the mapping from the original path to the current path for each backup set and archivelog piece.
For example, in the preceding query result, if you need to use the archivelog piece whose
BACKUP_PIECEis1for restore but the file has been moved toS3://test_bucket/archive/piece_1, you must specify the new pathS3://test_bucket/archive/piece_1when you execute theADD RESTORE SOURCEstatement to load the backup path.Execute the
ADD RESTORE SOURCEstatement to load the backup sets and archivelog pieces to be restored.The syntax is as follows:
ALTER SYSTEM ADD RESTORE SOURCE 'restore_path';The parameters in the syntax are described as follows:
restore_path: Specifies the path of the backup set or archivelog piece to load. You can specify one or more paths.Notice
If the backup sets or archivelog pieces to load are stored on object storage, the paths of all backup sets or archivelog pieces must have the same
host,access_id, andaccess_keysettings.You can execute this statement multiple consecutive times in the same session. The system incrementally adds the execution results to the restore source list.
Here is an example:
Load the backup set to be restored.
obclient [oceanbase]> ALTER SYSTEM ADD RESTORE SOURCE 's3://ob_backup/data/backup_set_1_full?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***';Load the archivelog piece to be restored.
obclient [oceanbase]> ALTER SYSTEM ADD RESTORE SOURCE 's3://ob_backup/archive/piece_d1002r1p1,s3://ob_backup/archive/piece_d1002r1p2?host=obs.***.myhuaweicloud.com&access_id=***&access_key=***';obclient [oceanbase]> ALTER SYSTEM ADD RESTORE SOURCE 'S3://test_bucket/archive/piece_1?host=***&access_id=x****&access_key=****';
(Optional) If you find that the specified path of the backup set or archivelog piece is incorrect during loading, execute the following statement to clear the previous input, and then reload the backup set or archivelog piece from the correct path.
obclient [oceanbase]> ALTER SYSTEM CLEAR RESTORE SOURCE;Call the
RESTOREstatement after the loading from all the specified paths is completed.Notice
- You must execute the
RESTOREstatement in the same session as theADD RESTORE SOURCEstatement. If the original session is interrupted or you use a new session, the previously loaded restore source list is cleared. - After you execute the
ADD RESTORE SOURCEstatement, you cannot restore a tenant by executing theRESTOREstatement with a specified backup destination in the same session. - After you execute the
RESTOREstatement, the previously loaded restore source list is cleared regardless of whether the restore succeeds. If you want to call theRESTOREstatement again, you must reload the backup sets and archivelog pieces to be restored.
The syntax is as follows:
ALTER SYSTEM RESTORE restore_tenant_name [UNTIL {TIME='timestamp' | SCN=scn} ] WITH 'restore_option';For more information about the statement, see RESTORE.
For more information about the parameters, see Introduction to physical restore parameters.
Here are some examples:
Restore the
mysqltenant from the specified paths to the SCN1658285759724047000, and set the resource pool torestore_pool.// Full restore obclient [oceanbase]> ALTER SYSTEM RESTORE mysql UNTIL SCN = 1712650554000909004 WITH 'pool_list=restore_pool';Restore the
mysqltenant from the specified paths to the timestamp2024-04-09 16:15:54, and set the resource pool torestore_pool.// Full restore obclient [oceanbase]> ALTER SYSTEM RESTORE mysql UNTIL TIME = '2024-04-09 16:15:54' WITH 'pool_list=restore_pool';
- You must execute the
What to do next
After you initiate a restore task, you can view the restore progress and results in views. For more information, see View the physical restore progress.
After the restore task is completed, if you restore backup data from a lower version to a cluster of a higher version, you must also upgrade the restored tenant. For more information, see Upgrade a tenant after restore is complete.
A tenant after physical restore is a standby tenant. It can subsequently provide services as a standby tenant or be converted to a primary tenant to provide services. For more information about how to continue log archiving and replay logs from the source tenant as a standby tenant, see Segment-based log replay for a standby tenant; for more information about how to convert a standby tenant into a primary tenant, see Convert a standby tenant into a primary tenant.