You can initiate a cluster-level (all tenants) backup of OceanBase Database in obshell in two ways:
Call an API
Use an obshell command
This topic describes how to initiate a cluster-level backup in obshell for an OceanBase cluster with three replicas.
Prerequisites
The OceanBase cluster has been managed by obshell. For more information about how to determine whether the OceanBase cluster is managed by obshell and how to take over the cluster, see Take over a non-obshell-deployed cluster.
All OBServer nodes of the OceanBase cluster and obshell are running.
Deployment modes
The following table describes the three servers used in this topic (obshell uses the default port 2886):
| Role | IP Address | Description |
|---|---|---|
| OBServer node | 10.10.10.1 | Zone 1 of OceanBase Database |
| OBServer node | 10.10.10.2 | Zone 2 of OceanBase Database |
| OBServer node | 10.10.10.3 | Zone 3 of OceanBase Database |
Back up the cluster by using an API
Note
obshell will verify the security of the called API. Therefore, you must encrypt the request and configure the encrypted request header (${request_headers}) and request body (${request_body}) in the curl command before you call the API each time.
Step 1: (Optional) Set the cluster-level backup configuration
You can call the /api/v1/obcluster/backup/config API of any obshell to set the cluster-level backup configuration.
Note
If you have already configured a cluster-level backup, you do not need to call this API again.
For more information about how to call the corresponding API in the CLI, see Set the cluster-level backup configuration. This API creates an asynchronous task. For more information about how to query the task progress, see Get task details. Wait for the task to complete, and then the configuration is completed.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/obcluster/backup/config
The request body before encryption is as follows:
{
"backup_base_uri":"file:///data/backup",
"log_archive_concurrency":50
}
For more information about how to request the corresponding API method by using obshell-sdk-python, see Set the cluster-level backup configuration.
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.post_cluster_backup_config_sync(
"file:///data/backup",
log_archive_concurrency=100,
)
...
For more information about how to request the corresponding API method by using obshell-sdk-go, see Set the cluster-level backup configuration.
...
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
request := client.V1().NewClusterBackupConfigPostRequest("file:///data/backup")
request.SetArchiveLagTarget("10s").SetLogArchiveConcurrency(100).
dag, err := client.V1().ClusterBackupConfigSyncWithRequest(request)
...
Step 2: Initiate a cluster-level backup
You can call the /api/v1/obcluster/backup API of any obshell to initiate a cluster-level backup.
For more information about how to call the corresponding API in the CLI, see Initiate a cluster-level backup. This API creates an asynchronous task. For more information about how to query the task progress, see Get task details. Wait for the task to complete, and then the backup is completed.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/obcluster/backup
The request body before encryption is as follows:
{
"mode":"full"
}
For more information about how to request the corresponding API method by using obshell-sdk-python, see Initiate a cluster-level backup.
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.start_cluster_backup_sync("full")
...
For more information about how to request the corresponding API method by using obshell-sdk-go, see Initiate a cluster-level backup.
...
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
request := client.V1().NewClusterBackupRequest()
request.SetBackupMode("full")
dag, err := client.V1().ClusterBackupWithRequest(request)
...
Step 3: View the cluster-level backup task
You can call the /api/v1/obcluster/backup/overview API of any obshell to view the cluster-level backup task.
For more information about how to call the corresponding API in the CLI, see View the cluster-level backup task.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X GET http://10.10.10.1:2886/api/v1/obcluster/backup/overview
For more information about how to request the corresponding API method by using obshell-sdk-python, see View the cluster-level backup task.
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.get_cluster_backup_overview()
...
For more information about how to request the corresponding API method by using obshell-sdk-go, see View the cluster-level backup task.
...
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
res, err := client.V1().GetClusterBackupOverview()
...
Back up the cluster by using an obshell command
Step 1: Execute a cluster backup
You can execute the obshell cluster backup command on any node to configure the cluster-level backup and initiate a backup. For more information about this command, see obshell cluster commands.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster backup -u 'file:///data/backup'
Step 2: Query the backup task
For more information about this command, see obshell backup commands.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell backup show