You can use the ALTER SYSTEM BACKUP statement to initiate a data backup. OceanBase Database supports full backup and incremental backup.
A full backup backs up all macroblocks. An incremental backup backs up all macroblocks generated and modified since the last full backup.
In addition to using the default path specified by the system parameter data_backup_dest, you can also use the TO '<dest>' syntax to back up data to a specified path. This is a one-time operation that does not modify the system parameter or affect subsequent automatic scheduled backups. For more information, see Back up to a specified directory.
Note
For V4.4.2, the feature of specifying a backup target path is supported starting from V4.4.2 BP3.
Limitations and considerations
Before you initiate a data backup, make sure that the archive mode is enabled and the
STATUSof the log archive job isDOING.For more information about how to view the status of a log archive job, see View the archiving progress.
For more information about the syntax for enabling the archive mode, see ARCHIVELOG.
Make sure that a full backup has been performed. If you initiate an incremental backup when no full backup is available, the system automatically downgrades the incremental backup to a full backup.
In the scenario where a cluster is upgraded from a lower version to a later version (the current version), even if the current tenant has already performed a full backup in the lower version, if you directly initiate an incremental backup after the upgrade, the system automatically downgrades the incremental backup to a full backup.
When you use the
TO '<dest>'syntax to specify a backup target path, note the following limitations:- The system tenant can only specify one tenant by using the
TOsyntax. You cannot initiate backups for multiple tenants at the same time. This is because multiple tenants would share the same target root path, which would cause backup sets of different tenants to overwrite each other. - If no historical backups exist in the specified target path (first-time backup), the incremental backup is automatically downgraded to a full backup.
- The system tenant can only specify one tenant by using the
Required privileges
Only the root user of the sys tenant (root@sys) or the administrator user of a user tenant can execute this statement.
- The default administrator user in MySQL-compatible mode is
root. - The default administrator user in Oracle-compatible mode is
SYS.
Syntax
ALTER SYSTEM backup_action [DESCRIPTION [=] 'description'];
backup_option:
BACKUP DATABASE [TO 'dest'] [PLUS ARCHIVELOG]
| BACKUP TENANT [=] {tenant_name[, tenant_name]...} [TO 'dest'] [PLUS ARCHIVELOG]
| BACKUP INCREMENTAL DATABASE [TO 'dest'] [PLUS ARCHIVELOG]
| BACKUP INCREMENTAL TENANT [=] tenant_name [TO 'dest'] [PLUS ARCHIVELOG]
Parameters
Parameter |
Description |
|---|---|
| PLUS ARCHIVELOG | If you specify the PLUS ARCHIVELOG keyword, the archive logs are also backed up during data backup, and a complete data set with archive logs will be generated in the backup directory. Since this data set is restorable, you can use it to restore the tenant data to the MIN_RESTORE_SCN position (the latest restorable SCN of the backup set) without relying on archive logs. |
| tenant_name | The name of the tenant to be backed up. This parameter is used in the sys tenant. If you specify multiple tenants, separate the tenant names with commas (,). When you use the TO 'dest' syntax to specify the backup target path, you can specify only one tenant. If you want to specify all user tenants, you must execute the ALTER SYSTEM BACKUP [INCREMENTAL] DATABASE statement in the sys tenant.
NoticeWhen you execute this statement in the |
| INCREMENTAL | Indicates an incremental backup. |
| dest | The backup target path. This parameter is optional. If you do not specify this parameter, the default path specified by the system parameter data_backup_dest is used. This syntax is a one-time operation. It does not modify the system parameter or affect subsequent automatic scheduled backups.
NoticeWhen you use the |
| description | The description of the operation. This parameter is optional. |
Examples
Assume that the current cluster contains three tenants: sys, mysql_tenant, and oracle_tenant, and that backup preparations have been completed for the mysql_tenant and oracle_tenant tenants.
systenantIn the
systenant, initiate a full data backup for all user tenants in the cluster.obclient [oceanbase]> ALTER SYSTEM BACKUP DATABASE;After the statement is executed, the system initiates a full data backup for the
mysql_tenantandoracle_tenanttenants in the cluster.In the
systenant, initiate a full data backup for themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM BACKUP TENANT = mysql_tenant;In the
systenant, initiate a full data backup that also backs up archive logs for themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM BACKUP TENANT = mysql_tenant PLUS ARCHIVELOG;After the statement is executed, the system generates a complete data set with archive logs in the data backup path of the tenant. If you use OceanBase Database Community Edition or OceanBase Database in standalone mode, you can use this data set to create a standby tenant in the physical standby database scenario. For more information, see Create a standby tenant by using the BACKUP DATABASE PLUS ARCHIVELOG feature.
In the
systenant, initiate an incremental data backup for all user tenants in the cluster.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL DATABASE;In this example, after the statement is executed, the system initiates an incremental data backup for the
mysql_tenantandoracle_tenanttenants in the cluster.In the
systenant, initiate an incremental data backup for themysql_tenanttenant.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL TENANT = mysql_tenant;In the
systenant, initiate a full data backup for themysql_tenanttenant with the specified backup target path.obclient [oceanbase]> ALTER SYSTEM BACKUP TENANT = mysql_tenant TO 'file:///data/backup/one_time_dest';In the
systenant, initiate an incremental data backup for themysql_tenanttenant with the specified backup target path.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL TENANT = mysql_tenant TO 'file:///data/backup/one_time_dest';In the
systenant, initiate a full data backup for themysql_tenanttenant with the specified backup target path and also back up archive logs.obclient [oceanbase]> ALTER SYSTEM BACKUP TENANT = mysql_tenant TO 'file:///data/backup/self_contained_dest' PLUS ARCHIVELOG;In the
systenant, initiate an incremental data backup for themysql_tenanttenant with the specified backup target path and also back up archive logs.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL TENANT = mysql_tenant TO 'file:///data/backup/self_contained_dest' PLUS ARCHIVELOG;
User tenant
In the
mysql_tenanttenant, initiate a full data backup for the current tenant.obclient [oceanbase]> ALTER SYSTEM BACKUP DATABASE;In the
oracle_tenanttenant, initiate a full data backup that also backs up archive logs for the current tenant.obclient [SYS]> ALTER SYSTEM BACKUP DATABASE PLUS ARCHIVELOG;In the
mysql_tenanttenant, initiate an incremental data backup for the current tenant.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL DATABASE;In the
mysql_tenanttenant, initiate a full data backup for the current tenant with the specified backup target path.obclient [oceanbase]> ALTER SYSTEM BACKUP DATABASE TO 'file:///data/backup/one_time_dest';In the
mysql_tenanttenant, initiate an incremental data backup for the current tenant with the specified backup target path.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL DATABASE TO 'file:///data/backup/one_time_dest';In the
mysql_tenanttenant, initiate an incremental data backup for the current tenant with the specified backup target path and also back up archive logs.obclient [oceanbase]> ALTER SYSTEM BACKUP INCREMENTAL DATABASE TO 'file:///data/backup/self_contained_dest' PLUS ARCHIVELOG;In the
mysql_tenanttenant, initiate a full data backup for the current tenant with the specified backup target path and also back up archive logs.obclient [oceanbase]> ALTER SYSTEM BACKUP DATABASE TO 'file:///data/backup/self_contained_dest' PLUS ARCHIVELOG;
