Stop backup cleanup

2023-08-01 06:02:28  Updated

In the current version, you can stop only automatic backup cleanup jobs. To stop an automatic backup cleanup job, delete the cleanup strategy first and then stop the automatic backup cleanup job so that the job will not be scheduled again. To cancel an ongoing cleanup job, you do not need to delete the cleanup strategy.

Delete a cleanup strategy

Considerations

  • If you delete all cleanup strategies for a tenant, automatic cleanup is disabled for the tenant.

  • Deleting a cleanup strategy does not affect ongoing cleanup jobs. When the system schedules automatic cleanup the next time, no cleanup job will be generated for the deleted cleanup strategy.

Delete a cleanup strategy of a user tenant from the sys tenant

  1. Log on to the sys tenant of the cluster as the root user.

  2. Execute the following statement to delete a cleanup strategy.

    obclient [(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name TENANT tenant_name;
    
    • The POLICY parameter specifies the name of the cleanup strategy to be deleted. You can query the CDB_OB_BACKUP_DELETE_POLICY view for the strategy.

    • The TENANT parameter specifies the name of a user tenant. To delete a cleanup strategy of a user tenant from the sys tenant, you must specify the name of the user tenant.

    To delete the cleanup strategy named default for the MySQL tenant from the sys tenant, execute the following statement:

    obclient [(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default' TENANT MySQL;
    

Delete a cleanup strategy in a user tenant

  1. Log on to the database as a tenant administrator.

    Note

    The administrator user of a MySQL user tenant is root and that of an Oracle user tenant is SYS.

  2. Execute the following statement to delete a cleanup strategy.

    obclient [(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY policy_name;
    

    The POLICY parameter specifies the name of the cleanup strategy to be deleted. You can query the oceanbase.DBA_OB_BACKUP_DELETE_POLICY or sys.DBA_OB_BACKUP_DELETE_POLICY view for the cleanup strategies configured for the current tenant.

    To delete the cleanup strategy named default for the current tenant, execute the following statement:

    obclient [(none)]> ALTER SYSTEM DROP DELETE BACKUP POLICY 'default';
    

Verify whether a cleanup strategy has been deleted

After you delete a cleanup strategy, you can query views to verify whether the cleanup strategy has been deleted.

  1. Log on to the database as an administrator of the sys tenant or a user tenant.

  2. Verify whether the cleanup strategy has been deleted.

    • In the sys tenant, query the oceanbase.CDB_OB_BACKUP_DELETE_POLICY view to verify whether the cleanup strategy of the specified tenant has been deleted.

      For example:

      obclient [(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_POLICY  WHERE tenant_id = 1002;
      Empty set
      
    • In a user tenant, query the oceanbase.DBA_OB_BACKUP_DELETE_POLICY or sys.DBA_OB_BACKUP_DELETE_POLICY view to verify whether the cleanup strategy of the current tenant has been deleted.

      • MySQL tenant

        obclient [(none)]> SELECT * FROM oceanbase.DBA_OB_BACKUP_DELETE_POLICY;
        
      • Oracle tenant

        obclient [SYS]> SELECT * FROM sys.DBA_OB_BACKUP_DELETE_POLICY;
        

    If the cleanup strategy of the tenant does not exist in the view, the cleanup strategy has been deleted.

What to do next

After you delete the cleanup strategy, set a new cleanup strategy as soon as possible. Otherwise, backup files can use up the disk space, affecting subsequent backup operations. For more information about how to set a cleanup strategy, see Automatic cleanup of expired backup data.

Cancel cleanup jobs

Cancel the ongoing cleanup jobs of a user tenant

  1. Log on to the database as a tenant administrator.

  2. Execute the following statement to stop the ongoing cleanup jobs of the current tenant:

    obclient [(none)]>  ALTER SYSTEM CANCEL DELETE BACKUP;
    

Cancel ongoing cleanup jobs from the sys tenant

  1. Log on to the sys tenant of the cluster as the root user.

  2. Execute the following statement to stop the ongoing cleanup jobs of a specified tenant:

    obclient [(none)]> ALTER SYSTEM CANCEL DELETE BACKUP TENANT tenant_name_list;
    

    The TENANT parameter specifies the name of the user tenant whose cleanup jobs are to be canceled. You can specify multiple user tenant names. The ongoing cleanup jobs of the specified user tenant will be canceled.

    To cancel the ongoing cleanup jobs of the MySQL and Oracle tenants from the sys tenant, execute the following statement. For example:

    obclient [(none)]> ALTER SYSTEM CANCEL DELETE BACKUP TENANT MySQL, Oracle;
    

    If you do not specify the TENANT parameter, the ongoing cleanup jobs of all user tenants are canceled.

    obclient [(none)]> ALTER SYSTEM CANCEL DELETE BACKUP;
    

Verify whether a cleanup job has been stopped

After you stop a cleanup job, you can query views to verify whether the cleanup job has been stopped.

  1. Log on to the database as an administrator of the sys tenant or a user tenant.

  2. Verify whether the cleanup job has been stopped.

    1. Query whether the cleanup job is ongoing.

      You can query the oceanbase.CDB_OB_BACKUP_DELETE_JOBS view from the sys tenant to view the execution status of the cleanup jobs of all tenants. You can query the oceanbase.DBA_OB_BACKUP_DELETE_JOBS or sys.DBA_OB_BACKUP_DELETE_JOBS view in the current user tenant to check the execution status of its cleanup jobs.

      To query the execution status of the cleanup jobs of a specified user tenant from the sys tenant, execute the following statement:

      obclient [(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOBS WHERE tenant_id = 1002\G
      *************************** 1. row ***************************
                      TENANT_ID: 1002
                         JOB_ID: 1
                    INCARNATION: 1
            INITIATOR_TENANT_ID: 1002
               INITIATOR_JOB_ID: 7
             EXECUTOR_TENANT_ID: 1002
                           TYPE: DELETE OBSOLETE BACKUP
                      PARAMETER: 2022-05-31 12:09:40.060284
                      JOB_LEVEL: USER_TENANT
                START_TIMESTAMP: 2022-06-01 12:09:53.389512
                  END_TIMESTAMP:
                         STATUS: CANCELING
                     TASK_COUNT: 2
             SUCCESS_TASK_COUNT: 1
                         RESULT: 0
                        COMMENT:  
      1 row in set
      

      If the value of STATUS is INIT, DOING, or CANCELING, the corresponding cleanup job is still ongoing.

      If you cannot query the ongoing cleanup jobs of a user tenant in the preceding views, you can query the history of cleanup jobs to verify the execution result of a cleanup job.

      obclient [(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOBS where tenant_id = 1002;
      Empty set
      
    2. Query historical cleanup jobs.

      You can query the oceanbase.CDB_OB_BACKUP_DELETE_JOB_HISTORY view from the sys tenant for the historical cleanup jobs of all tenants. You can query the oceanbase.DBA_OB_BACKUP_DELETE_JOB_HISTORY view from a user tenant in MySQL mode or the sys.DBA_OB_BACKUP_DELETE_JOB_HISTORY view from a user tenant in Oracle mode for the historical cleanup jobs of the current tenant.

      To query the historical cleanup jobs of a specified user tenant from the sys tenant, execute the following statement:

      obclient [(none)]> SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOB_HISTORY where tenant_id = 1002\G
      *************************** 1. row ***************************
                     TENANT_ID: 1002
                        JOB_ID: 1
                   INCARNATION: 1
           INITIATOR_TENANT_ID: 1002
              INITIATOR_JOB_ID: 7
            EXECUTOR_TENANT_ID: 1002
                          TYPE: DELETE OBSOLETE BACKUP
                     PARAMETER: 2022-05-31 12:09:40.060284
                     JOB_LEVEL: USER_TENANT
               START_TIMESTAMP: 2022-06-01 12:09:53.389512
                 END_TIMESTAMP: 2022-06-01 12:10:36.829576
                        STATUS: CANCELED
                    TASK_COUNT: 2
            SUCCESS_TASK_COUNT: 2
                        RESULT: 0
                       COMMENT:
      1 row in set
      

      If the value of STATUS is COMPLETED, FAILED, or CANCELED, the corresponding cleanup job has been stopped.

Contact Us