This topic describes how to initiate a log backup after you prepare for backup.
Prerequisites
Preparations for backup are completed.
Procedure
Log on to the
systenant as therootuser.(Optional) Configure the backup mode and enable compression of archived logs.
The backup mode can be configured as Optional or Mandatory. The default backup mode is Optional.
The optional mode prioritizes user business. In this mode, logs may be recycled before they are archived, interrupting the backup.
The mandatory mode prioritizes backup. In this mode, you may be unable to write more data before existing data is backed up.
You can use the zstd_1.3.8 and lz4_1.0 algorithms to compress archived logs. The default compression algorithm is lz4_1.0.
The following example selects the optional mode and enables the compression of archived logs:
obclient> ALTER SYSTEM SET backup_log_archive_option = 'optional compression= enable';You can dynamically switch the compression algorithm as needed by executing the following statement:
obclient> ALTER SYSTEM SET backup_log_archive_option='optional compression= zstd_1.3.8'; obclient> ALTER SYSTEM SET backup_log_archive_option='optional compression= lz4_1.0';Note
To disable the compression of archived logs, execute the following statement:
- In optional mode, you can either execute the
ALTER SYSTEM SET backup_log_archive_option = 'compression= disable';statement to disable compression, or execute theALTER SYSTEM SET backup_log_archive_option = 'mandatory compression= disable';statement to configure the backup mode and disable log compression. - In mandatory mode, you can only execute the
ALTER SYSTEM SET backup_log_archive_option = 'optional compression= disable';statement to configure the backup mode and disable log compression.
Execute the following statement to enable log backup:
Note
To save some time, we recommend that you initiate a minor compaction before enabling log backup. This is because log backup starts from the last minor compaction. For more information about how to initiate a minor compaction, see Manually initiate a minor compaction.
obclient> ALTER SYSTEM ARCHIVELOG;After log backup is enabled, OceanBase Database regularly backs up the transaction logs generated by the clusters to the specified destination.
Execute the following statement to check whether the log backup task is started:
obclient> SELECT * FROM CDB_OB_BACKUP_ARCHIVELOG;When
STATUSisDOING, the log backup task is started.For more information about fields in CDB_OB_BACKUP_ARCHIVELOG, see CDB_OB_BACKUP_ARCHIVELOG.
Execute the following statement to view the status of backup pieces in the backup set:
obclient> SELECT * FROM CDB_OB_BACKUP_PIECE_FILES;For more information about fields in CDB_OB_BACKUP_PIECE_FILES, see CDB_OB_BACKUP_PIECE_FILES.