OceanBase Deployer (obd) allows you to back up and restore tenants by using commands since V3.2.0. This topic describes the tenant backup and restore procedures.
Note
To use obd commands for backup and restore, make sure that the cluster involved is managed by obd. Otherwise, obd cannot obtain the cluster information. By default, a cluster deployed by using obd is managed by obd. For a cluster not deployed by using obd, you first need to use obd to take over the cluster. For more information, see Use obd to take over a cluster.
- For more information about obd commands used in this topic, see Cluster commands.
Prerequisites
Make sure that the following conditions are met:
You have installed obd V3.2.0 or later. We recommend that you install the latest version. For more information, see Install obd.
obshell has been installed in the cluster where the tenant to back up or restore resides and is running properly.
You have configured an appropriate backup destination.
Back up a tenant
This section describes how to back up the obmysql tenant in the test cluster. You need to modify related information based on the actual situation. We recommend that you use Alibaba Cloud Object Storage Service (OSS) as the backup destination.
Note
You cannot use backup commands to back up the sys tenant.
Configure the backup information.
OSSNFSAWS S3obd cluster tenant set-backup-config test obmysql -d 'oss://oceanbase-test-bucket/backup/data?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete' -a 'oss://oceanbase-test-bucket/backup/log?host=****.aliyun-inc.com&access_id=****&access_key=****&delete_mode=delete'Here,
oss://indicates that OSS is used as the backup destination type, the bucket name isoceanbase-test-bucket, the storage paths in the bucket are/backup/dataand/backup/log, and?is used to separate other parameters of the path. Thehostparameter specifies the host address of the bucket. Theaccess_idandaccess_keyparameters specify the access key of the account to access OSS. The cleanup mode is set todelete.For more information about the parameters in data backup path, see SET DATA_BACKUP_DEST.
obd cluster tenant set-backup-config test obmysql -d 'file:///data/nfs/backup/data' -a 'file:///data/nfs/backup/log'obd cluster tenant set-backup-config test obmysql -d 's3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****&delete_mode=delete' -a 's3://oceanbase-test-bucket/backup/log?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****&delete_mode=delete'Here,
s3://indicates that S3 is used as the backup destination type, the bucket name isoceanbase-test-bucket, the storage paths in the bucket are/backup/dataand/backup/log, and?is used to separate other parameters of the path. Thehostparameter specifies the domain name of S3. Theaccess_idandaccess_keyparameters specify the access key of the account to access S3. Thes3_regionparameter is required, and it specifies the region where the S3 bucket is located. The cleanup mode is set todelete.For more information about the parameters in data backup path, see SET DATA_BACKUP_DEST.
Perform backup.
Perform full backupPerform incremental backupobd cluster tenant backup test obmysqlobd cluster tenant backup test obmysql -m incrementalView the backup task.
obd cluster tenant backup-show test obmysqlHere is an example of viewing the backup task of the
obmysqltenant in thetestcluster. The OBServer node in this example is10.10.10.1. You must modify the information based on the actual situation. The output is as follows, where the value of thetask_statuscolumn isCOMPLETED, indicating backup success.+---------------------------------------------------------------------------------------------------------+ | backup task details of backup tenant obmysql | +-----------+----------------------------------+----------------------------------+-------------+---------+ | tenant_id | start_timestamp | end_timestamp | task_status | comment | +-----------+----------------------------------+----------------------------------+-------------+---------+ | 1002 | 2025-03-26T14:56:47.623096+08:00 | 2025-03-26T14:58:15.234362+08:00 | COMPLETED | - | +-----------+----------------------------------+----------------------------------+-------------+---------+(Optional) Cancel the backup task.
obd cluster tenant backup-cancel test obmysqlYou can run this command to cancel a backup task not in the
COMPLETEDstate. A few minutes after this command is executed, you can run theobd cluster tenant backup-showcommand to verify whether the backup task has been successfully canceled. The output is as follows, where the value of thetask_statuscolumn isCANCELED, indicating that the backup task has been canceled.+--------------------------------------------------------------------------------------------------------------------+ | backup task details of backup tenant obmysql | +-----------+----------------------------------+----------------------------------+-------------+--------------------+ | tenant_id | start_timestamp | end_timestamp | task_status | comment | +-----------+----------------------------------+----------------------------------+-------------+--------------------+ | 1002 | 2025-03-26T15:15:49.728777+08:00 | 2025-03-26T15:16:18.547451+08:00 | CANCELED | Operation canceled | +-----------+----------------------------------+----------------------------------+-------------+--------------------+
Restore a tenant
This section describes how to create the restore_1 tenant in the obtest cluster and restore the backup data to this tenant. You must modify the information based on the actual situation.
Perform restore.
OSSNFSAWS S3[root@ob-WB01191894-20250325105059 ~]# obd cluster tenant restore obtest restore_1 'oss://oceanbase-test-bucket/backup/data/?host=***.aliyun-inc.com&access_id=***&access_key=***' 'oss://oceanbase-test-bucket/backup/log/?host=***.aliyun-inc.com&access_id=***&access_key=***' --memory_size=2G --max_cpu=2You can use command options to configure resources available for the tenant to restore. If you do not specify the options, all remaining resources of the cluster are used to create the tenant. For more information, see the obd cluster tenant restore section in Cluster commands.
[root@ob-WB01191894-20250325105059 ~]# obd cluster tenant restore obtest restore_1 'file:///data/nfs/backup/data' 'file:///data/nfs/backup/log' --memory_size=2G --max_cpu=2You can use command options to configure resources available for the tenant to restore. If you do not specify the options, all remaining resources of the cluster are used to create the tenant. For more information, see the obd cluster tenant restore section in Cluster commands.
[root@ob-WB01191894-20250325105059 ~]# obd cluster tenant restore obtest restore_1 's3://oceanbase-test-bucket/backup/data?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****' 's3://oceanbase-test-bucket/backup/log?host=s3.<region>.amazonaws.com&access_id=****&access_key=****&s3_region=****' --memory_size=2G --max_cpu=2You can use command options to configure resources available for the tenant to restore. If you do not specify the options, all remaining resources of the cluster are used to create the tenant. For more information, see the obd cluster tenant restore section in Cluster commands.
View the restore task.
obd cluster tenant restore-show obtest restore_1Here is an example of viewing the restore task of the
restore_1tenant in theobtestcluster. You must modify the information based on the actual situation. The output is as follows, where the value of thetask_statuscolumn isSUCCESS, indicating restore success.+--------------------------------------------------------------------------------------------------------+ | restore task details of restore tenant restore_1 | +-----------+----------------------------------+---------------------------------+-------------+---------+ | tenant_id | start_timestamp | end_timestamp | task_status | comment | +-----------+----------------------------------+---------------------------------+-------------+---------+ | 1 | 2025-03-26T15:27:00.930773+08:00 | 2025-03-26T15:32:11.33193+08:00 | SUCCESS | - | +-----------+----------------------------------+---------------------------------+-------------+---------+View tenants in the cluster.
obd cluster tenant show obtestThe output is as follows:
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant basic info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | sys | SYS | MYSQL | RANDOM | 3.0 | 3.0 | 1G | 9223372036854775807 | 9223372036854775807 | 2G | 3 | PRIMARY | | restore_1 | USER | MYSQL | RANDOM | 2.0 | 2.0 | 2G | 9223372036854775807 | 9223372036854775807 | 6G | 2 | PRIMARY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+(Optional) Cancel the restore task.
You can run the following command to cancel the restore task of a tenant. Note that you can cancel only a restore task not in the
SUCCESSstate.obd cluster tenant restore-cancel obtest restore_1To verify whether the restore task has been successfully canceled, you can run the
obd cluster tenant showorobd cluster tenant restore-showcommand. If theobtesttenant is not displayed in the output of theobd cluster tenant showcommand, or if an error indicating that theobtesttenant does not exist is returned for theobd cluster tenant restore-showcommand, the task has been successfully canceled.
References
For more information about the backup and restore feature of OceanBase Database, see Introduction to physical backup and restore.
For more information about the parameters in data backup path, see SET DATA_BACKUP_DEST.