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
tenant_identifier:
TENANT_ID = tenant_id | TENANT_NAME = 'name'
tenant_name_list:
tenant_name [, tenant_name ...]
Parameters
| Parameter | Description |
|---|---|
| BACKUP_DEST = 'backup_url' | 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 = 'backup_backup_url' | The path to store the secondary backup. 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.
|
| {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" under "Perform secondary backup" in OceanBase Database Administrator Guide. |
| TENANT_ID = tenant_id | The ID of the tenant. |
| TENANT_NAME = '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, Network File System (NFS), and Cloud Object Storage (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';Performs 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/";