Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Chinese Database Backup & Recovery: OceanBase, TiDB, OpenGauss, GaussDB & GoldenDB
Databases 29 min read

Chinese Database Backup & Recovery: OceanBase, TiDB, OpenGauss, GaussDB & GoldenDB

This article compares backup and recovery implementations across five major Chinese databases—OceanBase, TiDB, OpenGauss, GaussDB, and GoldenDB—detailing their backup types, storage media, recovery granularity, command-line tools, and architectural approaches for point-in-time recovery.

Database Backup Recovery Solutions

Database backup is an indispensable part of production operations management. When production business data is lost or corrupted, backup data can quickly restore data to recover business. Typical database backup schemes include:

Database tools perform backup to local or NAS files , then centralized backup devices manage them uniformly.

Database backup tools back up data to remote or cloud storage devices such as COS or OBS, then centralized backup devices manage them uniformly.

Third-party tools agent directly backs up the database to centralized backup devices for management.

In the above backup schemes, the first requirement is to meet backup recovery bandwidth needs —whether local or cloud storage devices can meet the timeliness requirements for backup and recovery. The second is the impact of the backup process —impact on the primary database and business, and whether standby databases are supported. The third is data recovery consistency requirements —whether point-in-time recovery (PITR) to a consistent point is supported, which is a capability of each database product itself. The last is backup recovery task management and monitoring —backup success/failure, timeout, cancellation, etc., operable through a unified management platform.

Domestic Database Backup Recovery Functions

OceanBase Database

Backup and recovery is a core component of OceanBase's high reliability. Full backup and recovery functions are available via pure SQL commands. OceanBase supports tenant-level physical backup, including data and archived logs:

Data backup includes tenant-related information and all user table data—i.e., Major SSTable + Minor SSTable at backup time—divided into full backup and incremental backup.

Log archiving is performed by OBServer nodes periodically archiving log data to a specified backup path—i.e., Clog generated by the transaction layer, containing data modified after SSTable.

Supported backup media include OSS, NFS, COS, AWS S3, and S3-compatible object storage (e.g., Huawei OBS).

OceanBase supports tenant-level and table-level recovery : tenant-level recovery rebuilds a new tenant from existing backup data; table-level recovery restores user-specified tables from backup data into an existing tenant (supported since V4.2.1).

Log Archiving

Log archiving is handled by the Leader replica of each log stream. Logs are backed up at the Log Entry level (physical backup), with a default backup period of 2 minutes. Each archived log is a log collection (Log Group) containing multiple Log Entries, each with an associated SCN; the Log Group's SCN is the maximum SCN among its Log Entries.

1) Enable and disable log archiving

# Enable archive mode for specified tenant
ALTER SYSTEM ARCHIVELOG TENANT = mysql_tenant;
# Disable archive mode for specified tenant in cluster
ALTER SYSTEM NOARCHIVELOG TENANT = mysql_tenant;

2) View archive information

# View archive-related parameters for current tenant
SELECT * FROM oceanbase.DBA_OB_ARCHIVE_DEST;

Data Backup

The data backup process is scheduled by the Root Service node and performed per log stream. Backup data includes partition metadata and macroblock data. Physical backup refers to macroblock data physical backup; metadata is serialized in-memory values. Data backup preferentially selects Follower replicas.

1) Configure tenant backup destination

# Configure backup destination for specified tenant
ALTER SYSTEM SET DATA_BACKUP_DEST= 'data_backup_path' TENANT = mysql_tenant;

2) Initiate full backup

# Set backup concurrency
ALTER SYSTEM SET ha_low_thread_score = 10;
# Initiate full data backup for specified tenant
ALTER SYSTEM BACKUP TENANT = mysql_tenant [PLUS ARCHIVELOG];

Data Recovery

OceanBase supports tenant-level and table-level recovery. Tenant recovery guarantees cross-table, cross-partition global consistency. Tenant recovery process:

RS creates required log streams based on backup data.

Log stream Leader schedules its own data and log recovery; Followers pull data and logs from Leader.

RS detects all log streams recovered, then considers tenant data recovery complete.

Recovery supports within the same cluster or across different clusters.

1) Tenant recovery

# Recover to specified timestamp
ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL TIME='timestamp' WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
# Recover to specified SCN
ALTER SYSTEM RESTORE dest_tenant_name FROM uri UNTIL SCN=scn WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];
# Recover to latest position
ALTER SYSTEM RESTORE dest_tenant_name FROM uri WITH 'restore_option' [WITH KEY FROM 'backup_key_path' ENCRYPTED BY 'password'] [DESCRIPTION description];

After recovery, if restoring from a lower-version backup to a higher-version cluster, the restored tenant must be upgraded. If the restored tenant is a standby tenant, it can serve as standby or be promoted to primary.

2) Table-level recovery

Table-level recovery restores user-specified tables from backup data into an existing tenant (same tenant, different tenant in same cluster, or tenant in different cluster). An auxiliary tenant is used: first restore data to specified time point in auxiliary tenant; then cross-tenant import specified tables into target tenant; finally clean up auxiliary tenant.

ALTER SYSTEM 
RECOVER TABLE infodb.tbl1,infodb.tbl2 
TO TENANT oracle001 
FROM 'file:///data/nfs/backup/data,file:///data/nfs/backup/archive' 
UNTIL TIME='2023-09-30 00:00:00' 
WITH 'pool_list=restore_pool'
REMAP TABLE infodb.tbl1:newtbl 
REMAP TABLEGROUP tg1:newtg1
REMAP TABLESPACE ts1:newts1;

Table-level recovery only supports user tables. The specified table names must match the system's actual stored table names.

TiDB Database

TiDB supports full cluster data backup at a specific point in time— snapshot data, which includes all data satisfying transaction consistency at a physical time point . To meet PITR arbitrary point-in-time recovery needs, log backup must be enabled—i.e., recording KV change data in TiKV. Based on cluster snapshot backup and log backup data, recovery to any point in time (PITR) is possible.

Snapshot Backup and Recovery

Snapshot backup and recovery is implemented by the BR tool . Process:

Backup process

BR receives backup command br backup full.

BR schedules backup data: creates backup request, sends to TiKV nodes, request includes backup ts, regions to back up, backup storage address.

TiKV receives request, initializes backup worker.

TiKV backs up data: reads data corresponding to backup ts from Region (only leader), uploads SST files to backup storage.

BR collects backup results from each TiKV.

BR backs up metadata and uploads to backup storage.

Recovery process

BR receives restore command br restore, obtains snapshot backup storage address, databases/tables to restore.

BR schedules recovery data: based on PD-assigned Region distribution, sends restore requests to corresponding TiKV nodes, including backup data and rewrite rules.

TiKV receives request, initializes restore worker.

TiKV restores data: restore worker ingests processed SST files into RocksDB.

Restore worker returns restore result to BR.

BR collects restore results from all TiKV; if all succeed, restore task succeeds.

Log Backup and PITR Recovery

Backup process

BR receives br log start command, parses checkpoint ts (log backup start position) and backup storage address.

TiKV monitors log backup task creation and updates.

TiKV log backup observer continuously backs up KV change logs: reads KV data changes, saves to custom backup files, periodically uploads log backup data and local metadata to backup storage.

TiDB Coordinator monitors log backup progress, calculates global checkpoint ts from each Region's checkpoint ts, reports to PD.

PD persists log backup task status; queryable via br log status.

PITR recovery process

BR receives br restore point command, parses full backup data address, log backup data address, target restore timestamp.

BR restores full backup (snapshot backup data recovery).

BR restores log backup: reads log backup data, creates log restore requests, sends to corresponding TiKV.

TiKV receives request, initializes log restore worker.

TiKV restores log backup data: log restore worker rewrites backup data KV according to restore cluster table IDs, writes processed KV into store (RocksDB) via Raft interface.

BR collects restore results from all TiKV; if all succeed, restore task succeeds.

BR Backup Recovery Usage

TiDB supports writing backup data to Amazon S3, NFS, etc. BR commands perform backup/recovery.

1) Cluster snapshot backup

tiup br backup full --pd "${PD_IP}:2379" \
    --backupts '2022-09-08 13:30:00 +08:00' \
    --storage "" \
    --ratelimit 128 \

2) Restore snapshot backup data

tiup br restore full --pd "${PD_IP}:2379" \
--storage ""

3) Restore specified database/table data

tiup br restore table --pd "${PD_IP}:2379" \
--db "test" \
--table "usertable" \
--storage ""

4) Enable log backup

tiup br log start --task-name=pitr --pd "${PD_IP}:2379" \
--storage ''

5) Perform PITR recovery

tiup br restore point --pd "${PD_IP}:2379" \
--storage='' \
--full-backup-storage='' \
--restored-ts '2022-05-15 18:00:00+0800'

Note: TiDB backup impacts cluster performance (IO, transaction latency, QPS). Use --ratelimit to throttle backup tasks, and backup.num-threads to limit worker threads.

OpenGauss Database

OpenGauss supports logical and physical backup:

Logical backup dumps table data to files, suitable for small data volumes, data migration, or schema changes.

Physical backup copies physical files at disk block level, generally used for full backup/recovery scenarios.

Logical Backup and Recovery

OpenGauss logical backup uses gs_dump , exporting a database or its objects (schemas, tables, views). gs_dump supports exporting to plain-text SQL script files or archive files:

Plain-text SQL script files: contain SQL statements to restore database to saved state. Run via gsql to restore.

Archive format files: contain data to restore database, can be tar, directory archive, or custom archive format; must use gs_restore to restore.

Additionally, gs_dumpall exports all database information , including metadata, tablespaces, and SQL scripts for each database. To ensure consistency and integrity, gs_dumpall sets shared locks on tables to dump; if a table cannot be locked within specified time, backup fails.

Physical Backup and Recovery

OpenGauss physical backup tools include gs_backup and gs_basebackup: gs_backup exports database parameter files and binaries, suitable for small data volumes; gs_basebackup performs full copy of database binary files, combined with PITR for point-in-time recovery.

1) gs_backup backup

# Backup database host
gs_backup -t backup --backup-dir=BACKUPDIR [-h HOSTNAME] [--parameter] [--binary] [--all] [-l LOGFILE]
# Restore database host
gs_backup -t restore --backup-dir=BACKUPDIR [-h HOSTNAME] [--parameter] [--binary] [--all] [-l LOGFILE] [--force]

2) gs_basebackup

gs_basebackup copies server database files binary using replication protocol. It only supports full backup of primary and standby, not incremental backup.

3) PITR Recovery

OpenGauss PITR supports recovery to any time point after backup archive. Currently only primary node can perform PITR; standby must full build to match primary. During PITR, archived WAL log files are copied to pg_xlog, and recovery to specified time point is achieved by replaying logs on top of backup data.

4) gs_probackup

gs_probackup manages OpenGauss backup/recovery, supports periodic recovery, full, incremental, and remote backup.

# Initialize backup directory
gs_probackup init -B backup_dir
# Add a new backup instance
gs_probackup add-instance -B backup_dir -D data_dir --instance instance_name
# Create backup for specified instance
gs_probackup backup -B backup_dir --instance instance_name -b backup_mode
# Restore data from specified instance backup
gs_probackup restore -B backup_dir --instance instance_name -D pgdata-path -i backup_id

GaussDB Database

GaussDB provides cluster-level/table-level physical backup based on OBS/NAS storage media, and cluster-level/table-level recovery in homogeneous databases (same shard count, same major version). Supports full and incremental backup. Uses distributed parallel technology to back up/restore each data instance's data files in parallel, delivering high backup/recovery performance. Also provides backup data compression, backup throttling, breakpoint resume.

Full backup (as shown) backs up full data files and incremental logs up to barrier LSN . For PITR recovery, based on full/incremental backup sets and archived logs, instances are restored to any point in time.

1) Roach Backup Recovery Tool

GaussRoach.py is GaussDB's utility for backup and recovery, capable of backing up data, WAL archived logs, and run logs for the entire database. It can backup/restore clusters or single tables; backup to physical disk, OBS, or NAS; restore clusters from cluster-level backups, or restore databases/tables from cluster-level backups.

# Backup cluster to NAS
python3 GaussRoach.py -t backup --master-port 6000 --media-destination /home/userA/media --media-type NAS --metadata-destination /home/userA/metadata --cluster-unique-id gaussdb_backup
# Backup table to NAS
python3 GaussRoach.py -t backup --master-port 6000 --media-destination /home/userA/media --media-type NAS --metadata-destination /home/omm/metadata --cluster-unique-id gaussdb_backup --gbr-table-list /data/table.json
# Restore cluster from NAS
python3 GaussRoach.py -t restore --clean --master-port 6000 --media-destination /home/userA/media --media-type NAS --backup-key 20160121_190548 --metadata-destination /home/userA/metadata --cluster-unique-id gaussdb_backup
# Restore single table from NAS
python3 GaussRoach.py -t restore --clean --master-port 6000 --media-destination /home/userA/media --media-type NAS --backup-key 20160121_190548 --metadata-destination /home/userA/metadata --cluster-unique-id gaussdb_backup --restore-new-cluster --gbr-table-list /data/table.json --aux-db-path /data/aux_db --origin-cluster --gbr-owner 'user1' -U user

GoldenDB Distributed Database

GoldenDB backup includes data file backup, binlog backup, active GTID backup, metadata backup, and Sequence backup. Supports full and incremental backup; data backup is performed at database level.

Data file backup : uses xtrabackup, all backup files stored in "$DNip_FULL_$back_start_time.xbstream".

Binlog backup : backs up DN node binlogs to specified directory for data consistency recovery.

Active transaction GTID backup : backs up cluster GTID list to specified directory to ensure global node data consistency.

Cluster metadata : backs up data dictionary, user passwords, index information.

Sequence information : backs up auto-increment column attributes: database name, table name, start value, step, min, max, current value.

1) Data backup process

Insight page creates scheduled backup task in backup_restore library, sends dbtool message to CM.

When CM timer triggers, CM sends backup request to each node's DBAgent.

DBAgent receives request, saves backup files to specified backup directory.

DBAgent feeds backup completion result back to CM.

CM collects results from all DBAgents, summarizes to MDS.

MDS receives backup result, sends to OMM for storage.

2) Data recovery process

Obtain files required for recovery.

Restore DN using full backup files (and incremental files).

Apply binlog files.

Roll back active transactions at recovery point.

3) Backup recovery impact

GoldenDB supports backup on standby nodes. Backup and recovery affect local disk IO; backup process also incurs a brief flush table with read lock.

Summary

Comparing domestic databases, each possesses full backup and data consistency recovery capabilities, as shown in the table below.

The overall timeliness of database backup and recovery depends on data volume, backup storage device performance, and bandwidth —the ability to support high concurrency and high throughput. Especially in centralized databases where a single database exceeds 10TB, ensuring rapid business recovery via backup data during failures is critical.

References:

https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000000818529

https://docs.pingcap.com/zh/tidb/stable/br-snapshot-guide

https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/DatabaseOMGuide/

https://doc.hcs.huawei.com/db/zh-cn/gaussdb/24.1.30/usermanual/gaussdb_01_247.html

https://www.goldendb.com/#/docsIndex/docs/BackupRecovery_BasicPrinciples

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

TiDBdatabase backupdatabase recoveryOceanBasepoint-in-time recoveryopenGaussGaussDBGoldenDB

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion