Backup and restore is a core component of the high availability feature of OceanBase Database. It is mainly used to ensure data security, including preventing storage media damage and user errors. If data is lost due to storage media damage or user errors, you can restore the data by using the restore feature.
Overview
The backup and restore module of OceanBase Database provides features such as backup, backup verification, restore, and cleanup.
Backup
OceanBase Database supports tenant-level physical backup. A physical backup consists of data backup and log archiving. Therefore, the physical backup feature is a combination of data backup and log archiving. Here, a tenant refers to a user tenant. Physical backup is not supported for the sys tenant or the Meta tenant.
Data backup refers to the feature of backing up data. This feature is divided into full backup and incremental backup:
Full backup refers to backing up all macroblocks.
Incremental backup refers to backing up macroblocks added or modified since the last backup.
Notice
Before you perform a physical backup, you must enable the log archiving mode.
The data backed up by data backup includes the following:
Information about the tenant, including the tenant name, cluster name, time zone (timezone), replica distribution (locality), and compatibility mode (MySQL or Oracle) of the tenant.
All user table data
Note
Data backup backs up system variables and tenant-level configuration items, but does not back up cluster-level configuration items or private system table data.
Log archiving refers to the automatic archiving of log data. OBServer nodes periodically archive log data to the specified backup path. This process is fully automatic and does not require external triggering. After the log archiving service is enabled, the data dictionary is also archived.
Backup verification
The backup verification feature of OceanBase Database is mainly used to solve the problems of the integrity and correctness of backup and archive data. You can actively verify whether the backup set and archive logs are missing files, have physical data damage, or logical inconsistencies without performing actual restore operations.
Backup verification is divided into Basic verification and Physical verification based on the verification level. Specifically:
Basic verification: only checks the completeness of the file list.
Physical verification: checks the correctness and logical consistency of physical data.
Backup verification supports verification at different granularities, including verification of the entire backup and archive path, verification of specified backup sets or log archive pieces, and verification of specified paths across clusters.
Restore
The overall architecture of physical restore is as follows:
Physical restore supports tenant-level restore and table-level restore.
Tenant-level restore: Tenant-level restore is the process of rebuilding a new tenant based on the existing data backup. Tenant-level restore ensures global consistency across tables and partitions.
Table-level restore: Table-level restore is the process of restoring a user-specified table from the backup data to an existing tenant. The existing tenant can be the same as the original tenant, a different tenant within the same cluster, or a tenant in a different cluster.
Tenant-level restore supports full restore and quick restore.
Notice
After a tenant is restored by using quick restore, the tenant cannot be manually merged, cannot be backed up, and cannot be switched to or failover to the primary database. The tenant can only exist as a standby database.
Full restore: Full restore refers to restoring macroblock data and incremental logs. After all data is restored from the backup media to the local environment, the restored tenant can provide services. The full restore process includes the restore and recover processes for tenant system tables and user tables. Restore refers to restoring the baseline data required for the restore to the OBServer node of the target tenant. Recover refers to restoring the logs corresponding to the baseline to the corresponding OBServer node.
Quick restore: Quick restore refers to providing services to users without restoring macroblock data. This reduces the restore waiting time and lowers the user's usage cost.
Select the restore time point for your physical restore.
Complete restore: No restore timestamp is specified.
Incomplete restore with a specified SCN or timestamp: SCN is the precise version number of OceanBase Database. In Oracle-compatible mode, the timestamp is precise to the nanosecond, with no precision loss. In MySQL-compatible mode, the timestamp is precise to the microsecond, with precision loss after the microsecond.
For more information about the physical restore process, see Restore process.
Cleanup
OceanBase Database provides automatic and manual cleanup capabilities for backup data, so that you can flexibly handle different business scenarios.
Automatic cleanup: An automatic cleanup mechanism based on the recovery window (recovery_window). After you set the expiration time for backup data, the system periodically triggers cleanup tasks to remove expired backup sets and data archive pieces.
Manual cleanup: Manual cleanup is divided into two types. The first type is manual cleanup of specified backup sets or log archive pieces. The second type is manual cleanup of all backup sets or data archive pieces in the entire path (data backup path or log archive path).
Backup media requirements
OceanBase Database of the current version supports backup media such as Alibaba Cloud OSS, NFS, Azure Blob, AWS S3, and object storage services that are compatible with the S3 protocol (such as Huawei OBS, Google GCS, and Tencent Cloud COS). Some of these backup media require meeting certain basic requirements before they can be used.
SDK version requirements
In the current version, obdal is used by default to access object storage. obdal is a unified framework for object storage developed based on OpenDAL. For more information about OpenDAL, see OpenDAL.
In addition, if you want to use the SDK of an object storage service, the version of the object storage service's SDK must correspond to the version of the observer component. The following table describes the correspondence between the versions of the object storage service's SDK and the observer component.
oss-c-sdk |
s3-cpp-sdk |
|
|---|---|---|
| 4.3.4 and later | 3.11.2 | 1.11.156 |
Interface requirements
Alibaba Cloud OSS:
The following table describes the interfaces supported by Alibaba Cloud OSS.
Interface nameDescriptionPutObject Uploads a single object. DeleteObject Deletes a single object. DeleteObjects Deletes objects in batches. GetObject Retrieves an object. ListObjects Lists all objects in the storage space (strong consistency is required). HeadObject Retrieves the metadata of an object. AppendObject Uploads an object in append mode. PutObjectTagging (optional) Sets or updates the tags of an object. GetObjectTagging (optional) Retrieves the tags of an object. InitiateMultipartUpload Initializes a multipart upload. UploadPart Uploads a part. CompleteMultipartUpload Merges the uploaded parts into one object. AbortMultipartUpload Aborts a multipart upload and deletes the uploaded parts. ListMultipartUploads Lists the information of initialized but not completed or not terminated multipart uploads. ListParts Lists the uploaded parts in an upload task. Only the V1 signature algorithm is supported.
NFS: The version must be NFS 3 or later.
Object storage services compatible with the S3 protocol (for example, Huawei OBS, Google GCS, and Tencent Cloud COS):
The following table describes the S3 APIs that must be supported.
Interface nameDescriptionPutObject Uploads a single object. DeleteObject Deletes a single object. DeleteObjects Deletes objects in batches. GetObject Downloads a single object. ListObjects Lists all objects under the specified path. HeadObject Retrieves the metadata of an object. PutObjectTagging (optional) Sets the tags of an object. GetObjectTagging (optional) Retrieves the tags of an object. CreateMultipartUpload Initializes a multipart upload. UploadPart Uploads a single part. CompleteMultipartUpload Merges the uploaded parts into one object. AbortMultipartUpload Aborts a multipart upload and deletes the uploaded parts. ListMultipartUploads Lists the uploaded parts. ListParts Lists the uploaded parts in an upload task. The object access URL must support the virtual-hosted-style access method. For more information about virtual-hosted-style requests, see AWS S3 documentation.
Before you select a backup media, you can run the test_io_device command in the ob_admin tool to verify whether the I/O interfaces and I/O permissions provided by the backup media meet the requirements for backup and restore. You can also run the io_adapter_benchmark command in the ob_admin tool to view the read and write performance between an OBServer node and the backup media, which can be used as a reference for backup performance. For more information about the test_io_device and io_adapter_benchmark commands, see test_io_device and io_adapter_benchmark.
Directory structure
Data backup directory
The directories created by the data backup feature at the backup destination and the types of files stored in each directory are as follows:
data_backup_dest
├── format.obbak // Formatted information of the backup path
├── check_file
│ └── 1002_connect_file_20230111T193020.obbak // Connectivity check file
├── backup_sets // A summary directory of the data backup list, which records the list of all data backup sets
│ ├── backup_set_1_full_end_success_20230111T193420.obbak // Placeholder for the end of a full backup
│ ├── backup_set_1_full_start.obbak // Placeholder for the start of a full backup
│ ├── backup_set_2_inc_start.obbak // Placeholder for the start of an incremental backup
│ └── backup_set_2_inc_end_success_20230111T194420.obbak // Placeholder for the end of an incremental backup
└── backup_set_1_full // A full backup set. A name ending with full indicates a full backup, and inc indicates an incremental backup.
├── file_list.0.obbak
├── backup_set_1_full_20230111T193330_20230111T193420.obbak // Placeholder that shows the start and end times of the full backup
├── single_backup_set_info.obbak // Metadata of the current backup set
├── tenant_backup_set_infos.obbak // Information about the full backup sets of the current tenant
├── infos
├── logstream_1 // Log stream 1
└── logstream_1001 // Log stream 1001
In the data backup directory, the top-level directory contains the following three types of data:
format.obbak: used to record the metadata of the backup path.check_file: used for connectivity check of the user data backup directory.backup_sets: a summary directory of the list of data backup sets, which records the list of all data backup sets.backup_set_1_full: the directory indicates a data backup set.backup_set_1indicates that thebackup_set_idof the backup set is1. If the directory name ends withfull, it indicates a full backup. If it ends withinc, it indicates an incremental backup. A backup set is generated for each data backup. After the data backup is completed, the backup set will no longer be modified.A data backup set mainly contains the following data:
file_list.0.obbak: this file records the files and directories contained in the current directory.backup_set_1_full_20230111T193330_20230111T193420.obbak: this file shows the ID, start time, and end time of the current backup set. This file is only for information display.single_backup_set_info.obbak: this file records the metadata of the current backup set, including the backup point and the dependent logs.tenant_backup_set_infos.obbak: this file records the metadata of all existing backup sets of the current tenant.infos: this directory records the metadata of the data backup set.logstream_1: this directory records all data of log stream 1. Log stream 1 is the system log stream of the OceanBase Database tenant.logstream_1001: this directory records all data of log stream 1001. Log streams with numbers greater than 1000 are the user log streams of the OceanBase Database tenant.
Cluster-level configuration item backup directory
Each time a backup of cluster-level configuration items is initiated, the system generates a backup file of the cluster-level configuration items in the specified directory. The directory structure is as follows:
cluster_parameters_backup_dest
├── cluster_parameter.20240710T103610.obbak # Information of non-default cluster-level configuration items. File naming format: `cluster_parameter.[timestamp]`
└── cluster_parameter.20241018T140609.obbak
Log archive directory
For backup media such as NFS, OSS, and Azure Blob, the directories created by the log archiving feature at the archive destination and the types of files stored in each directory are as follows:
log_archive_dest
├── check_file
│ └── 1002_connect_file_20230111T193049.obbak // Connectivity check file
├── format.obbak // Formatted information of the backup path
├── rounds // Placeholder directory for Rounds
│ └── round_d1002r1_start.obarc // Placeholder for Round start
├── pieces // Placeholder directory for Pieces
│ ├── piece_d1002r1p1_start_20230111T193049.obarc // Placeholder for Piece start, named as piece_DESTID_ROUNDID_PIECEID_start_DATE
│ └── piece_d1002r1p1_end_20230111T193249.obarc // Placeholder for Piece end, named as piece_DESTID_ROUNDID_PIECEID_end_DATE
└── piece_d1002r1p1 // Piece directory, named as piece_DESTID_ROUNDID_PIECEID
├── file_list.0.obarc
├── piece_d1002r1p1_20230111T193049_20230111T193249.obarc // Records the continuous interval of the Piece
├── checkpoint
├── single_piece_info.obarc // Records the metadata of the current Piece
├── tenant_archive_piece_infos.obarc // Records the metadata of all frozen Pieces before the current Piece
├── file_info.obarc // List of all log stream files
├── logstream_1 // Log stream 1
└── logstream_1001 // Log stream 1001
In the above log archive directory, the top-level directory contains the following three types of data:
format.obbak: records the metadata of the archive path, including information such as the tenant using the path.check_file: used for connectivity check of the user log archive directory.rounds: a summary list of all Rounds in the log archive, recording the list of all Rounds.pieces: a summary list of all Pieces in the log archive, recording the list of all Pieces.piece_d1002r1p1: the directory for a Piece in the log archive, named aspiece_DESTID_ROUNDID_PIECEID. Here,DESTIDrefers to the id corresponding tolog_archive_dest;ROUNDIDrefers to the id of the log archive Round, which is a monotonically increasing integer; andPIECEIDrefers to thepiece_idof the log archive Piece, which is also a monotonically increasing integer.A log archive Piece directory contains the following data:
file_list.0.obarc: this file records the files and directories contained in the current directory.piece_d1002r1p1_20230111T193049_20230111T193249.obarc: this file displays the id, start, and end times of the current Piece and is only for informational purposes.checkpoint: this directory is used by the active Piece to record the archive point. The ObArchiveScheduler module periodically updates the archive point information in this directory.single_piece_info.obarc: this file records the metadata of the current Piece.tenant_archive_piece_infos.obarc: this file records the metadata of all frozen Pieces in the current tenant.file_info.obarc: this file records the list of log stream files within the Piece.logstream_1: this directory records the log files of log stream 1, which is the system log stream of the OceanBase Database tenant.logstream_1001: this directory records the log files of log stream 1001. Log streams with numbers greater than 1000 are the user log streams of the OceanBase Database tenant.
Differences from V3.x/V2.x
Log archiving
Feature |
V3.x/V2.2x |
V4.x |
|---|---|---|
| Archiving level | Cluster level | Tenant level |
| Archiving granularity | Partition level | Log stream level |
| Permissions | You can only operate on the sys tenant, for example, to set the archiving path, enable archiving, and view the archiving progress. |
You can operate on the sys tenant or the administrator user of a user tenant. |
| Usage |
|
Use the ALTER SYSTEM SET LOG_ARCHIVE_DEST statement to set the tenant-level archiving path and piece switching cycle. By default, the cycle is 1d (1 day). The log archiving path and data backup path can be configured independently. |
| Piece switching | The piece switching feature is disabled by default. You can choose to disable it. | Only the piece switching feature is enabled, and the default cycle is 1 day. |
| Method to set the archiving delay | Use the ALTER SYSTEM SET LOG_ARCHIVE_CHECKPOINT_INTERVAL statement. |
Use the ALTER SYSTEM SET ARCHIVE_LAG_TARGET statement. |
Result of executing the ALTER SYSTEM ARCHIVELOG statement in the sys tenant |
Enables archiving for all tenants in the current cluster. New tenants created after archiving is enabled also have archiving enabled. | Enables archiving for all tenants in the current cluster. New tenants created after archiving is enabled do not have archiving enabled. |
| Log compression | Use the ALTER SYSTEM SET BACKUP_LOG_ARCHIVE_OPTION statement. |
Not supported. |
| Views | The following three views are related to archiving:
|
The following eight views are related to archiving:
|
| Media requirements | The media must be SSD. | The media can be HDD or SSD. |
| Number of files | The number of files is proportional to the number of partitions. In a scenario with millions of partitions, this results in a large number of small files. | The number of files is small and independent of the number of partitions. This avoids the issue of a large number of small files. |
| Standby archiving | Not supported. | Supported. |
Data backup
Feature |
V3.x/V2.2x |
V4.x |
|---|---|---|
| Backup level | Cluster-level | Tenant-level |
| Permissions | Only the sys tenant can perform backup operations, such as setting the backup path, initiating a backup, and viewing the backup progress. |
Both the sys tenant and the administrator of a user tenant can perform backup operations. |
| Backup path setting method | The cluster-level backup path can be set by using the ALTER SYSTEM SET BACKUP_DEST statement. |
The tenant-level backup path can be set by using the ALTER SYSTEM SET DATA_BACKUP_DEST statement. In addition, the data backup path and log archive path can be independently configured. |
| Data backup to a specified path | The sys tenant initiates data backup by executing the ALTER SYSTEM BACKUP TENANT tenant_name_list TO backup_destination; statement. |
Not supported |
| BACKUP PLUS ARCHIVELOG feature | Not supported | Supported |
| Space expansion | Snapshots are retained during backup, which causes storage space expansion during backup. | Snapshots are not retained, so no space expansion occurs. |
| Standby database backup | Not supported | Supported |
| Views | The following five views are related to backup:
|
The following 10 views are related to backup:
|
Physical restore
Feature |
V3.x/V2.2x |
V4.x |
|---|---|---|
| Data path | The cluster-level backup path is provided in the restore command. | The data backup path and log archive path must be provided. |
| Restore concurrency setting | Before initiating a restore command, the ALTER SYSTEM SET RESTORE_CONCURRENCY statement is used to set the restore concurrency. |
The concurrecy parameter is specified in the restore command. |
| Key management method |
|
|
| Tenant role after restore | The primary tenant, which is the primary database. | The standby tenant, which is the standby database. |
| Upgrade | The tenant is automatically upgraded during restore. | The tenant must be manually upgraded after restore. |
| Table-level restore | Supported. Only tables can be restored to a new tenant (a tenant created during restore). Tables cannot be restored to an existing tenant. | Supported starting from V4.2.1. Only tables can be restored to an existing tenant. Tables cannot be restored to a new tenant (a tenant created during restore). |
| Quick restore | Not supported | Supported starting from V4.3.3 |
Restore by using the ADD RESTORE SOURCE statement |
Supported | Not supported |
Partner certifications
For a list of partners that have completed certification with OceanBase Database, see Industrial partners.
On the Industrial partners page, select Data Integration & Backup > Backup & Recovery under Select Solution Type. This will display a list of partners that have completed certification with OceanBase Database, along with the certified versions and the validity periods of the certificates.
References
For more information about physical backup and restore, see Backup and restore.
