Purpose
You can use this statement to trigger a backup. For more information about how to back up and restore data in OceanBase Database, see "Backup and restoration management" in OceanBase Database Administrator Guide.
This statement can be executed only in the sys tenant.
Syntax
alter_system_backup_stmt:
ALTER SYSTEM backup_action;
backup_action:
SET BACKUP_DEST = 'backup_url'
| SET BACKUP_BACKUP_DEST = 'backup_backup_url'
| ARCHIVELOG | NOARCHIVELOG
| BACKUP DATABASE | BACKUP ARCHIVELOG
| BACKUP BACKUPPIECE ALL NOT BACKED UP n TIMES [tenant_identifier] [BACKUP_BACKUP_DEST='url']
| BACKUP BACKUPPIECE [= n] [tenant_identifier] [BACKUP_BACKUP_DEST='url'] [WITH ACTIVE BACKUPPIECE]
| BACKUP BACKUPSET ALL NOT BACKED UP n TIMES [tenant_identifier] [BACKUP_BACKUP_DEST='url']
| BACKUP BACKUPSET = n [tenant_identifier] [BACKUP_BACKUP_DEST='url']
| CANCEL BACKUP [BACKUPSET | BACKUPPIECE]
| {START | STOP} BACKUP ARCHIVELOG
| BACKUP TENANT tenant_name_list TO backup_destination
| CHANGE EXTERNAL_STORAGE_DEST PATH='backup_path' SET ACCESS_INFO='access_id=your_access_id&access_key=your_access_key'
tenant_identifier:
TENANT_ID = tenant_id | TENANT_NAME = 'tenant_name'
tenant_name_list:
tenant_name [, tenant_name ...]
Parameters and keywords
| Parameter/Keyword | Description |
|---|---|
| BACKUP_DEST | The path to store backups. You can set it to an Object Storage Service (OSS) bucket or a file. For more information about the syntax, see the following example. |
| BACKUP_BACKUP_DEST | The path to store secondary backups. You can set it to an OSS bucket or a file. |
| ARCHIVELOG | NOARCHIVELOG | Enables or disables log backup. Note: To initiate backup faster, we recommend that you trigger a minor compaction before enabling log backup. This is because log backup starts from the last minor compaction. |
| BACKUP DATABASE | Triggers a baseline backup (only cluster-level backup is supported). |
| BACKUP BACKUPPIECE | Performs secondary backup on log backups.
|
| BACKUP BACKUPSET | Performs secondary backup on data backups.
|
| CANCEL BACKUP | Cancels the current baseline backup. |
| CANCEL BACKUP {BACKUPSET | BACKUPPIECE} | Cancels the secondary backup on current backups.
BACKUP BACKUPPIECE, see "Perform secondary backup on multiple backup directories" of "Perform secondary backup" in the OceanBase Database Administrator Guide. |
| {START | STOP} BACKUP ARCHIVELOG | Starts or stops automatic secondary backup on log backups. Note: BACKUP ARCHIVELOG is not recommended. We recommend that you use BACKUP BACKUPPIECE. For more information about how to use BACKUP ARCHIVELOG, see "Secondary backup on logs in the splitting disabled mode" of "Perform secondary backup" in the OceanBase Database Administrator Guide. |
| EXTERNAL_STORAGE_DEST | The external storage destination. You can specify this parameter in a command for modifying the authorization information of the backup destination. Note
|
| PATH | The information that uniquely identifies a backup destination, including the backup path and endpoint information. Note
|
| ACCESS_INFO | The new values of access_id and access_key. Only access_id and access_key can be set in this parameter. In addition, access_id and access_key must be set in pair. |
| tenant_id | The ID of the tenant. |
| tenant_name | The name of the tenant. |
| tenant_name_list | The list of tenants whose data is to be backed up. Currently, you can add up to 256 tenants. |
| backup_destination | The destination that stores the backups. Currently, OSS, NFS, and COS can serve as the backup destination. |
Examples
Set the path to store the backup data.
obclient> ALTER SYSTEM SET backup_dest='oss://antsys-oceanbasebackup/backup_dir?host=xxx&access_id=xxx&access_key=xxx'; obclient> ALTER SYSTEM SET backup_dest='file:///data/nfs/physical_backup_dir';Perform secondary backup on log backups.
obclient> ALTER SYSTEM BACKUP BACKUPPIECE ALL NOT BACKED UP 2 TIMES BACKUP_BACKUP_DEST= 'file:///ob_backup_backup/ob_cluster_1_backup_piece_20200125'; obclient> ALTER SYSTEM BACKUP BACKUPPIECE 1 TENANT_NAME tenant_1 BACKUP_BACKUP_DEST= 'file:///ob_backup_backup/ob_cluster_1_backup_piece_20200225';Perform a backup at the tenant level.
obclient> ALTER SYSTEM BACKUP TENANT tenant1,tenant2 TO "file:///ob_backup/";Modify the authorization information, that is,
access_idandaccess_key, of the backup destination during the execution of a log backup task.obclient> ALTER SYSTEM CHANGE EXTERNAL_STORAGE_DEST PATH='oss://oceanbase-test-bucket/backup/?host=xxx.aliyun-inc.com' SET ACCESS_INFO='access_id=***&access_key=***';