How to monitor the CubeBackup service status (backup / storage / license) programmatically using CubeBackup APIs.


CubeBackup APIs can minimize the service maintenance hassle for administrators. You can use a script to monitor the backup, storage, license status of your CubeBackup instance, or integrate CubeBackup into your existing monitoring system without having to use the CubeBackup web console.

NOTE: Before following this guide, please be sure to enable the CubeBackup APIs and create an API client on your CubeBackup server.

The CubeBackup APIs can enable the following use cases for monitoring purposes:

  • A status query for the current backup event or the next backup due time. See more.
  • Accessing recent backup logs and error details for further diagnostics programmatically. See more.
  • A status query for the current CubeBackup license status and usage, which can be handled later for license re-assignment or subscription extension. See more.
  • A status query for the backup size of each domain or user, which can be handled later based on a customized limitation on the backup size or storage quota. See more.

Monitor the backup status

If you need to monitor the current backup status or retrieve the ongoing backup progress remotely, use the Retrieve the current backup task status API.

curl -L ".../api/v1/domains/mydomain.com/backup/status" \
  --header "Authorization:255c6...88111"

CubeBackup will return a backup status object containing the Status, as well as the scheduled time for the next backup in NextBackupStartIn or the detailed progress of an ongoing backup process in Detail. See the backup status object for a full list of arguments you can access for this object.

You can use these retrieved properties to automate the management of your CubeBackup instance to trigger or pause a backup on demand, update the throttle settings, adjust the backup interval, as well as many other use cases.

Retrieve the backup history and error logs

  1. To generate a sorted list of historical backup events, call the Retrieve the backup history API, passing along the optional parameters to filter the backup event list.

    curl -L "…/api/v1/domains/myDomain.com/backup/tasks?FailedOnly=true" \
      –header "Authorization:255c6…88111"
    

    CubeBackup will return a sorted array of backup event objects containing the unique Id, Status, ErrorCount and other statistical information for each backup event. You can also export an identical list in CSV format by calling the Retrieve backup histories in CSV format API.

    curl -L "…/api/v1/domains/myDomain.com/backup/tasks.csv?FailedOnly=true" \
      –header "Authorization:255c6…8811e"
    

  2. For diagnostic purposes, you can use the retrieved backup event Id to access detailed error logs. Call the Retrieve the backup event errors API, supplying the event Id in the URL as in the example below.

    curl -L "…/api/v1/domains/myDomain.com/backup/tasks/{{event_id}}/errors?Limit=20&PageNum=2" \
      –header "Authorization:255c6…88111"
    

    CubeBackup will return a list of backup error objects if there are any. You can also export an identical list in CSV format by calling the Retrieve backup errors in CSV format API.

    curl -L "…/api/v1/domains/myDomain.com/backup/tasks/{{event_id}}/errors.csv" \
      –header "Authorization:255c6…88111"
    

    See the backup error object for a full list of arguments you can access in this object.

Monitor the license usage status

To query the current license status, or retrieve the total number of users currently being backed up, call the Retrieve the license usage API.

curl -L ".../api/v1/license/display" \
  --header "Authorization:255c6...88111"

CubeBackup will return the License object containing the DomainCount, the ProtectedUserCount, the license DueTime, and many other attributes that can be used for further processing.

This can also be combined with batch update operations to integrate CubeBackup with an automatic license assignment system, in addition to many other use cases.

Monitor the backup size and the storage usage status

CubeBackup can send storage status and backup size detail updates automatically by email. You can also use CubeBackup APIs to query storage status and detailed backup size for domains or even individual users, and then make adjustments to the settings accordingly.

Call the Retrieve the storage status API to retrieve the current storage status of your backup repository.

curl -L ".../api/v1/storage/status" \
  --header "Authorization:255c6...88111"

CubeBackup will return the Storage status object with the basic storage type and backup size information. To further investigate the backup size of each domain or even user and shared drive, the following list outlines the APIs and the corresponding attributes which can be used for your status query:

  • Call the Retrieve domain status summary API to retrieve detailed backup and index size information of individual applications on the domain. See the Domain summary object for the full list of attributes CubeBackup will return in this API call.

    curl -L "…/api/v1/domains/mydomain.com/summary" \
      –header "Authorization:255c6…88111"
    

  • Call the Retrieve user details API and pass along the user Id from your previous request or database. This will retrieve the detailed backup and index size information of individual applications for the user. See the User object for the full list of attributes CubeBackup will return in this API call.

    curl -L "…/api/v1/domains/mydomain.com/users/{{user_id}}" \
      –header "Authorization:255c6…88111"
    

  • Call the Retrieve Shared drive details API and pass along the Shared drive Id from your previous request or database. This will retrieve detailed backup and index size information for a Shared drive. See the Shared drive object for the full list of attributes CubeBackup will return in this API call.

    curl -L "…/api/v1/domains/mydomain.com/shareddrives/{{shared_drive_id}}" \
      –header "Authorization:255c6…88111"