Before you back up data, you must configure the backup destination and backup key.
Backup architecture
Followers are preferentially used for backup. The following figure shows the backup architecture:

Configure the backup destination
Before you back up data, you must configure the DATA_BACKUP_DEST parameter. The sys tenant is used to manage the cluster and does not contain user data or support backup and restore. Therefore, you do not need to configure the DATA_BACKUP_DEST parameter for the sys tenant.
Log on to the database as an administrator of the
systenant or a user tenant.Note
The administrator user of a MySQL tenant is
rootand that of an Oracle tenant isSYS.Configure the backup destination.
OceanBase Database supports three types of media as the backup destination: Network File System (NFS), Alibaba Cloud Object Storage Service (OSS), and Tencent Cloud Storage (COS).
Configure the backup destination for a specified tenant in the sys tenant.
ALTER SYSTEM SET DATA_BACKUP_DEST= 'data_backup_path' TENANT = mysql_tenant;Configure the backup destination for the current tenant in a user tenant.
ALTER SYSTEM SET DATA_BACKUP_DEST= 'data_backup_path';
Notice
After upgrading OceanBase Database from V4.0.x to V4.1.0, it is necessary to change the archive path. However, when upgrading from V4.1.x to V4.2.1, there is no need to modify the archive path. Moreover, during the upgrade process from V4.1.x to V4.2.1, you have the option to archive logs.
Here are some examples:
NFS
Notice
When you use NFS as the backup destination, note the following points:
- The value of
data_backup_destcannot be a string with a question mark (?). - The value of
data_backup_destmust be set to an absolute path to ensure that the OBServer node has the write privilege on the backup destination. - Ensure that all OBServer nodes are mounted to NFS of the same server and use the parameter settings recommended in this topic. For more information about the procedure of mounting NFS, see Deploy NFS.
Set the backup destination to NFS:
obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST= 'file:///data/nfs/backup/data' TENANT = mysql_tenant;obclient [(none)]> ALTER SYSTEM SET DATA_BACKUP_DEST='file:///data/nfs/backup/data';- The value of
OSS
When you use OSS as the backup destination, you can set the backup destination and the
delete_modeparameter to configure the backup file cleanup mode. Thedelete_modeparameter can be set todeleteortagging. If you do not specifydelete_mode, the default cleanup modedeletetakes effect. For more information about thedelete_modeparameter, see View data backup parameter settings.Both of the following sample statements set the backup destination and configure a backup file cleanup mode:
ALTER SYSTEM SET DATA_BACKUP_DEST='oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=delete' TENANT = mysql_tenant;ALTER SYSTEM SET DATA_BACKUP_DEST='oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com&access_id=xxx&access_key=xxx&delete_mode=delete';For more information about the automatic cleanup of backup data in
deleteortaggingmode, see Automatic cleanup of expired backup data.COS
Notice
If you use COS as the archive destination, you must disable the list cache for buckets. Otherwise, backup data consistency errors may occur. For guidance on how to disable the list cache of a bucket, contact the technical support of COS.
Like OSS, COS also allows you to configure the cleanup mode of archive files by using the
delete_modeparameter in the same way as with OSS.To use COS as the backup destination, set the backup destination as follows in the sys tenant:
obclient> ALTER SYSTEM SET DATA_BACKUP_DEST='cos://oceanbase-test-appid/backup?host=cos.ap-xxxx.myqcloud.com&access_id=xxx&access_key=xxx&appid=xxx' TENANT = mysql_tenant;
Query the
CDB_OB_BACKUP_PARAMETERview from the sys tenant for the backup paths of all tenants in the current cluster. For more information, see View data backup parameter settings.
Considerations
After you configure the data_backup_dest parameter, by default, the system creates a file named format in the directory to which the specified destination belongs. This file is used to verify the validity information of the backup destination and ensure the integrity of data in the destination. Therefore, observe the following considerations when you configure the data_backup_dest parameter:
If the
formatfile does not exist, the directory where the configured destination is located must be empty so that theLOG_ARCHIVE_DESTparameter can be set. If this directory is not empty, the system returns the-9080error to indicate that theformatfile does not exist.If the
formatfile exists, its content must be verified so that the parameter can be set. Otherwise, the system returns the-9081error to indicate that theformatfile does not match. The content of theformatfile is verified to check whether the types of the cluster, tenant, and backup destination in the file match those of the current cluster, tenant, and backup destination.When you execute a backup job, the job fails to be initiated if the
formatfile does not exist or fails the verification.
Back up a key
Before you back up data, you must check the encryption status of the source tenant. If transparent encryption is configured for the source tenant, you must back up the key for the source tenant.
Notice
After you back up the key, if key rotation has been triggered for the source tenant, you need to back up the key of the source tenant again before you restore the data.
Log on to the database as an administrator of the
systenant or a user tenant.Back up a key.
You can back up the key for a specified tenant from the sys tenant:
ALTER SYSTEM BACKUP KEY TENANT = tenant_name TO 'backup_key_path' ENCRYPTED BY 'password';You can also back up the key for the current user tenant:
ALTER SYSTEM BACKUP KEY TO 'backup_key_path' ENCRYPTED BY 'password';
where
backup_key_pathspecifies the backup path of the key. This path is user-defined and cannot be the same as the data backup path or log archiving path.passwordspecifies the encryption password for the backup path of the key.
The following example shows how to back up the key of the
mysql_tenanttenant to thefile:///data_backup_dest/keypath from the sys tenant:obclient [(none)]> ALTER SYSTEM BACKUP KEY TENANT = mysql_tenant TO 'file:///data_backup_dest/key' ENCRYPTED BY '******';Check the back path of the key in views.
In the sys tenant, you can query the
CDB_OB_BACKUP_STORAGE_INFOview for the backup path of the key:SELECT * FROM oceanbase.CDB_OB_BACKUP_STORAGE_INFO;In a user tenant, you can query the
DBA_OB_BACKUP_STORAGE_INFOview for the backup path of the key:MySQL modeOracle modeSELECT * FROM oceanbase.DBA_OB_BACKUP_STORAGE_INFO;SELECT * FROM SYS.DBA_OB_BACKUP_STORAGE_INFO;For more information about the columns in the
CDB_OB_BACKUP_STORAGE_INFOandDBA_OB_BACKUP_STORAGE_INFOviews, see CDB_OB_BACKUP_STORAGE_INFO and DBA_OB_BACKUP_STORAGE_INFO, respectively.