This topic describes how to restore data from a backup.
Prerequisites
Data has been backed up and can be restored.
The cluster is running properly and the available resources are sufficient to create a recovery tenant.
Restore data in OceanBase Database V3.x
Configuration file for restoring data
The content of the configuration file for restoring data is as follows:
apiVersion: cloud.oceanbase.com/v1
kind: Restore
metadata:
name: ob-restore
namespace: obcluster
spec:
savePoint:
value: "2023-07-07 15:05:35.536997"
source:
clusterName: ob-test
clusterID: 1
tenant: tenant1
path:
root: file:///ob-backup
decryptionSecret: backup-secret
dest:
clusterName: ob-test
clusterID: 1
tenant: ob_restore
kmsEncryptInfo: ''
topology:
- zone: zone1
unitNum: 1
type:
name: FUll
replica: 1
priority: 3
resource:
maxCPU: 2500m
minCPU: 2
memorySize: 1Gi
The parameters are described as follows:
savePoint: the target savepoint to which data is to be restored.source: the information about the backup data, including the information about the cluster, tenant, and addresses of backup files.decryptionSecret: the secret for decrypting backup data if data encryption is configured during data backup. Make sure that the secret or the password in the secret is the same as that configured during backup.dest: the destination of restore, including the information about the cluster, the name of the tenant to be restored, and the resource configuration of the tenant.
Initiate data restore
Run the following command to initiate data restore:
kubectl apply -f restore.yaml
View the data restore status
Run the following command to view the restore result:
kubectl get restore -AThe returned result is as follows:
NAMESPACE NAME AGE obcluster cluster-restore 139mRun the following command to view the detailed restore result:
kubectl get restore cluster-restore -n obcluster -o yamlThe returned result is as follows:
apiVersion: cloud.oceanbase.com/v1 kind: Restore metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"cloud.oceanbase.com/v1","kind":"Restore","metadata":{"annotations":{},"name":"cluster-restore","namespace":"obcluster"},"spec":{"decryptionSecret":"backup-secret","dest":{"clusterID":1,"clusterName":"ob-314","kmsEncryptInfo":"","tenant":"restore_tenant","topology":[{"priority":3,"resource":{"maxCPU":2,"memorySize":"2Gi","minCPU":2},"type":{"name":"FUll","replica":1},"unitNum":1,"zone":"zone1"}]},"savePoint":{"value":"2023-07-24 22:35:35.536997"},"source":{"clusterID":1,"clusterName":"ob-314","path":{"root":"file:///ob-backup"},"tenant":"tenant3"}}} creationTimestamp: "2023-07-25T03:39:56Z" generation: 1 name: cluster-restore namespace: obcluster resourceVersion: "367773" uid: 01bf798b-f6e2-4cb2-87fd-1eae341dbd2b spec: decryptionSecret: backup-secret dest: clusterID: 1 clusterName: ob-314 kmsEncryptInfo: "" tenant: restore_tenant topology: - priority: 3 resource: maxCPU: 2 memorySize: 2Gi minCPU: 2 type: name: FUll replica: 1 unitNum: 1 zone: zone1 savePoint: value: "2023-07-24 22:35:35.536997" source: clusterID: 1 clusterName: ob-314 path: root: file:///ob-backup tenant: tenant3 status: finishTimestamp: "2023-07-24T22:35:35.536997+08:00" jobID: 2 status: RESTORE_SUCCESS
Restore data in OceanBase Database V4.x
Configuration file for restoring data
The content of the configuration file for restoring data is as follows:
apiVersion: cloud.oceanbase.com/v1
kind: Restore
metadata:
name: ob-restore
namespace: obcluster
spec:
savePoint:
type: time
value: "2023-07-07 15:05:35.536997"
source:
clusterName: ob-test
clusterID: 1
tenant: tenant1
path:
data: file:///ob-backup/t1/data
log: file:///ob-backup/t1/log
decryptionSecret: backup-secret
dest:
clusterName: ob-test
clusterID: 1
tenant: ob_restore
kmsEncryptInfo: ''
topology:
- zone: zone1
unitNum: 1
type:
name: FUll
replica: 1
priority: 3
resource:
maxCPU: 2500m
minCPU: 2
memorySize: 1Gi
The parameters are described as follows:
savePoint: the target savepoint to which data is to be restored. An SCN or point in time is supported. You can use thetypeparameter to specify the value type.source: the information about the backup data, including the information about the cluster, tenant, and addresses of backup files.decryptionSecret: the secret for decrypting backup data if data encryption is configured during data backup. Make sure that the secret or the password in the secret is the same as that configured during backup.dest: the destination of restore, including the information about the cluster, the name of the tenant to be restored, and the resource configuration of the tenant.
Initiate data restore
Run the following command to initiate data restore:
kubectl apply -f restore.yaml
View the data restore status
Run the following command to view the restore result:
kubectl get restore -AThe returned result is as follows:
NAMESPACE NAME AGE obcluster obtenant-restore 146mRun the following command to view the detailed restore result:
kubectl get restore obtenant-restore -n obcluster -o yamlThe returned result is as follows:
apiVersion: cloud.oceanbase.com/v1 kind: Restore metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"cloud.oceanbase.com/v1","kind":"Restore","metadata":{"annotations":{},"name":"obtenant-restore","namespace":"obcluster"},"spec":{"decryptionSecret":"obtenant-backup","dest":{"clusterID":1,"clusterName":"ob-test","kmsEncryptInfo":"","tenant":"obrestore","topology":[{"priority":3,"resource":{"maxCPU":2,"memorySize":"2Gi","minCPU":2},"type":{"name":"FUll","replica":1},"unitNum":1,"zone":"zone1"},{"resource":{"maxCPU":2,"memorySize":"2Gi","minCPU":2},"type":{"name":"Full","replica":1},"unitNum":1,"zone":"zone2"},{"resource":{"maxCPU":2,"memorySize":"2Gi","minCPU":2},"type":{"name":"Full","replica":1},"unitNum":1,"zone":"zone3"}]},"savePoint":{"type":"time","value":"2023-07-24 21:35:35.536997"},"source":{"clusterID":1,"clusterName":"ob-test","path":{"data":"file:///ob-backup/obtenant/data","log":"file:///ob-backup/obtenant/log"},"tenant":"obtenant"}}} creationTimestamp: "2023-07-25T03:33:17Z" generation: 1 name: obtenant-restore namespace: obcluster resourceVersion: "367159" uid: a2794a44-e58e-4741-b638-ab59ef397e66 spec: decryptionSecret: obtenant-backup dest: clusterID: 1 clusterName: ob-test kmsEncryptInfo: "" tenant: obrestore topology: - priority: 3 resource: maxCPU: 2 memorySize: 2Gi minCPU: 2 type: name: FUll replica: 1 unitNum: 1 zone: zone1 - resource: maxCPU: 2 memorySize: 2Gi minCPU: 2 type: name: Full replica: 1 unitNum: 1 zone: zone2 - resource: maxCPU: 2 memorySize: 2Gi minCPU: 2 type: name: Full replica: 1 unitNum: 1 zone: zone3 savePoint: type: time value: "2023-07-24 21:35:35.536997" source: clusterID: 1 clusterName: ob-test path: data: file:///ob-backup/obtenant/data log: file:///ob-backup/obtenant/log tenant: obtenant status: finishTimestamp: "2023-07-25T11:36:40.599879+08:00" jobID: 1 status: FINISHED
Check whether the tenant is restored
Connect to the sys tenant.
mysql -hxxx.xxx.xxx.xxx -P2881 -uroot oceanbase -A -cCheck whether the target tenant is restored.
select * from DBA_OB_TENANTS;