How to automate backup management and license assignment programmatically using CubeBackup APIs.


CubeBackup APIs also can be integrated into your systems to perform management tasks as required by your company. You can trigger a backup event on demand, batch update the backup list and automate other backup settings based on the response from previous status queries.

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

Trigger a backup on demand

CubeBackup APIs allow you to trigger or stop a backup anytime you wish, independent from the regularly scheduled backups.

  1. Call the Start a backup API to trigger a backup in a domain previously added to your CubeBackup instance, by supplying the domain name in the URL.

    curl -L \
      --request POST "…/api/v1/domains/mydomain.com/backup/start" \
      --header "Authorization:255c6…88111"
    

    This API will return "OK" in the response body once the backup successfully starts or there is already an ongoing backup process.

  2. Call the Stop a backup API to stop any ongoing backups for a domain, by supplying a domain name in the URL. No backup progress will be lost and subsequent backups will start from where they were left off.

    curl -L \
      --request POST "…/api/v1/domains/mydomain.com/backup/cancel" \
      --header "Authorization:255c6…88111"
    

This API will return "OK" in the response body if the backup successfully stopped or there is no ongoing backup process.

Bulk update the backup list

You can use CubeBackup APIs to retrieve the current backup list and update it according to specific conditions. CubeBackup APIs support batch operations to enable or disable the backup status for multiple users or Shared drives in a single request.

  1. Retrieve a list of items to update

    The following example outlines the APIs used to retrieve a list of users, Shared drives, Organization Units and domains. You can retrieve and store the list of items in your database to use later.

    • Call the List all domains API to retrieve an array of Domain objects.

      curl -L "…/api/v1/domains" \
        --header "Authorization:255c6…88111"
      

    • Call the List all Organization Units API to retrieve an array of Organization Unit objects for a domain.

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

    • Call the List all users API to retrieve an array of User objects for a domain.

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

    • Call the List all Shared drives API to retrieve an array of Shared drive objects for a domain.

      curl -L "…/api/v1/domains/mydomain.com/shareddrives" \
        --header "Authorization:255c6…88111"
      
      Each item retrieved in the list contains the unique Id, backup Status and many other useful attributes. You can use the unique Id of each item to update the backup list.

  2. Batch update user backup status

    Call the Batch update user backup status API to change the backup status of specific users based on the user Id retrieved from your previous request. Pass along the array of user Ids to be updated in the EnabledUserIds and DisabledUserIds parameters as a JSON payload.

    You can also update the user backup status using a list of email addresses in CSV format. A sample Python script can be found in our Git repository.

    curl -L \
      --request POST "…/api/v1/domains/mydomain.com/users/batch-update-backup-status" \
      --header "Authorization:255c6…88111" \
      --header "Content-Type: application/json" \
      --data '{
        "EnabledUserIds":["11386…68194",…],
        "DisabledUserIds":["19036…23942",…]
      }'
    
    CubeBackup will return "OK" in the response body once the user backup status has been successfully updated.

  3. Batch update Shared drive backup status

    Call the Batch update Shared drive backup status API to update the backup status of specific Shared drives based on the Shared drive Id retrieved from your previous request. Pass along the array of Shared drive Ids to be updated in the EnabledSharedDriveIds and DisabledSharedDriveIds parameters as a JSON payload.

    curl -L \
      --request POST "…/api/v1/domains/mydomain.com/shareddrives/batch-update-backup-status" \
      --header "Authorization:255c6…88111" \
      --header "Content-Type: application/json" \
      --data '{
        "EnabledSharedDriveIds":["0ANE…9PVA",…],
        "DisabledSharedDriveIds":["0PC2…AC3D",…]
      }'
    
    CubeBackup will return "OK" in the response body once the Shared drive backup status has been successfully updated.

  4. Batch update Organization Unit auto-backup status

    You can also update the auto-backup options of organizational units in a domain. By default, CubeBackup will automatically include new users in the backup list to help reduce admin workload.

    Call the Batch update OU auto-backup status API to enable/disable the auto-backup for new users based on the full path of organization units retrieved from your previous request. Pass along the OrgUnitPath array in the EnabledUnitPaths and DisabledUnitPaths parameters as a JSON payload.

    curl -L \
      --request POST "…/api/v1/domains" \
      --header "Authorization:255c6…88111" \
      --header "Content-Type: application/json" \
      --data '{
        "EnabledUnitPaths":["/OUa/enabled",…],
        "DisabledUnitPaths":["/OUb/disabled",…]
      }'
    
    CubeBackup will return "OK" in the response body once the Organization Unit auto-backup status has been successfully updated.

Configure backup options

Editing the system configuration or domain backup settings can also be easily handled under specific conditions using CubeBackup APIs. This can be useful in the following use cases.

  • Enable/Disable the throttle settings of the backup server based on the current office network status. See more.

  • Increase/Decrease the backup interval based on the server status or backup storage usage. See more.

  • Add the file exclusion rules for Google Drive backups. See more.

  • Configure the custom SMTP server for CubeBackup email reports. See more.

  • See more configuration options using CubeBackup APIs. See more.

Edit throttle settings

Before modifying the throttle setting, you can use the CubeBackup APIs to do a status query of the ongoing backup process. The up-to-date network usage of the CubeBackup service is passed in the RXBandwidth and TXBandwidth properties.

To modify the throttle settings, call the Update the system settings API, passing along the System settings object as a JSON payload with appropriate properties. The throttle settings will take effect immediately if there is an ongoing backup process.

curl -L \
  --request PATCH ".../api/v1/system/settings" \
  --header "Authorization:255c6...88111" \
  --header "Content-Type: application/json" \
  --data '{
    "NetworkBandwidthLimitWorkHoursEnabled": true,
    "NetworkBandwidthLimitWorkHoursRate": 50,
    "NetworkBandwidthLimitNonWorkHoursEnabled": true,
    "NetworkBandwidthLimitNonWorkHoursRate": 300,
    "NetworkBandwidthLimitWorkHoursBegin": 9,
    "NetworkBandwidthLimitWorkHoursEnd": 17,
    "NetworkBandwidthLimitDays": [1, 2, 3, 4, 5]
}'

CubeBackup will return "OK" in the response body once the throttle settings have been successfully updated. You can also perform another backup status query to confirm the updates.

Adjust backup intervals

You can adjust the scheduled backup interval based on storage status or any other custom conditions.

Call the Update the system settings API, passing along the System settings object as a JSON payload with the appropriate property BackupInterval.

The backup interval is counted in minutes, and will take effect on the next backup event for all domains in the CubeBackup instance.

curl -L \
--request PATCH ".../api/v1/system/settings" \
--header "Authorization:255c6...88111" \
--header "Content-Type: application/json" \
--data '{
  "BackupInterval": 120
}'

CubeBackup will return "OK" in the response body once the backup interval setting has been successfully updated.

Add file exclusion rules

CubeBackup file exclusion rules can help prevent specific Google Drive files from being backed up, and will be applied to all future backups in a domain.

  1. The CubeBackup API does not support adding a new rule directly, so you will need to retrieve the current file exclusion rules using the Retrieve domain settings API.

    The file exclusion rule is a string stored in the Drive.ExcludeRule attribute for the Domain settings object. Save it for future use.

  2. Append the new file exclusion rules to the retrieved string.

  3. Call the Update the domain settings API, passing along the Domain settings object as a JSON payload with the updated string as the new value of Drive.ExcludeRule.

    curl –location \
      --request PATCH "…/api/v1/domains/mydomain.com/settings" \
      --header "Authorization:255c6…88111" \
      --header "Content-Type: application/json" \
      --data '{
        "Drive": {
          "ExcludeRule": "size>10GB\nhas suffix \".mp4\", \".mkv\" AND size > 2GB\nname is \"deprecated\""
        }
      }'
    

  4. CubeBackup will perform syntax validation upon updating the file exclusion rules, and return "OK" in the response body once the file exclusion rules have been successfully updated.

Configure the custom SMTP server

Set up custom SMTP server settings or update credentials using the Update the system settings API.

Pass along the system settings object as a JSON payload with the appropriate properties.

curl -L \
  --request PATCH ".../api/v1/system/settings" \
  --header "Authorization:255c6...88111" \
  --header "Content-Type: application/json"\
  --data '{
    "SummaryEmailNotificationFrequency": 2,
    "SummaryEmailReceiver": "[email protected]",
    "SmtpEnabled": true,
    "SmtpHost": "smtp-relay.gmail.com",
    "SmtpPort": 587,
    "SmtpFrom": "[email protected]",
    "SmtpUsername": "[email protected]",
    "SmtpPassword": "",
    "SmtpSkipVerifyTLS": false
  }'

CubeBackup will return "OK" in the response body once the custom SMTP settings have been successfully updated.

More configuration options

See Update the system settings API and Update domain settings for a full list of configurable arguments you can pass to the CubeBackup APIs.