Sample uses of the CrashPlan API

This article applies to CrashPlan Enterprise and MSPs.png

Overview

You can use the CrashPlan API to create custom reports, perform automated actions, or integrate with existing systems within your organization. This article shows some of the many ways you can use the CrashPlan API to interact with your CrashPlan environment.

Before you begin

Several examples below use the Python JSON formatting tool (python3 -mjson.tool). If your system does not have Python 3, you can install it from the official download page.

GitHub

GitHub is a popular open source code repository and social platform for developers. You can find additional API examples, code libraries, scripts, and developer documentation on CrashPlan's GitHub page. Everyone is welcome to contribute. 

Examples

Computers

Backup status of devices sorted by user

The CrashPlan API makes it easy to see the last time a user's device was completely backed up. The following example uses the Computer resource and limits the output with active=true, includes backup usage, and sorts the output by the date of the most recent backup. Once the userID is known, this example could be altered to report only the details of a single user.


curl "https://console.us1.crashplan.com/api/v1/Computer?active=true&incBackupUsage=true&srtKey=lastBackup" -H 'Authorization: Bearer <auth_token>' | python3 -mjson.tool

Replace <auth_token> with an authentication token.

Sample output:

{
    "metadata": {
        "timestamp": "2014-08-07T15:31:21.466-05:00",
        "params": {
            "incBackupUsage": "true",
            "srtKey": "lastBackup",
            "active": "true"
        }
    },
    "data": {
        "computers": [
            {
                "computerId": 10,
                "name": "Alpha",
                "guid": "619174385806213377",
                "type": "COMPUTER",
                "status": "Active",
                "active": true,
                "blocked": false,
                "alertState": 0,
                "alertStates": [
                    "OK"
                ],
                "userId": 2,
                "orgId": 2,
                "parentComputerId": null,
                "lastConnected": "2014-08-07T15:14:04.234-05:00",
                "osName": "Linux",
                "osVersion": "3.2.0-4-686-pae",
                "osArch": "i386",
                "address": "127.0.0.1:4242",
                "remoteAddress": "127.0.0.1",
                "javaVersion": "1.6.0_27",
                "modelInfo": null,
                "timeZone": "US/Central",
                "version": 1375333203614,
                "productVersion": "3.6.1.4",
                "creationDate": "2014-08-01T16:37:51.131-05:00",
                "modificationDate": "2014-08-07T15:14:09.645-05:00",
                "loginDate": "2014-08-07T15:14:09.641-05:00",
                "backupUsage": [
                    {
                        "targetComputerId": 2,
                        "targetComputerParentId": null,
                        "targetComputerGuid": "647903643760066817",
                        "targetComputerName": "CrashPlan Server",
                        "targetComputerOsName": null,
                        "targetComputerType": "SERVER",
                        "selectedFiles": 8,
                        "selectedBytes": 21944,
                        "todoFiles": 0,
                        "todoBytes": 0,
                        "archiveBytes": 111170,
                        "billableBytes": 111170,
                        "sendRateAverage": 70139,
                        "completionRateAverage": 0,
                        "lastBackup": "2014-08-07T15:14:12.802-05:00",
                        "lastCompletedBackup": "2014-08-07T15:14:12.802-05:00",
                        "lastConnected": "2014-08-07T15:16:45.469-05:00",
                        "lastMaintenanceDate": "2014-08-01T16:38:13.955-05:00",
                        "lastCompactDate": null,
                        "modificationDate": "2014-08-07T15:16:45.469-05:00",
                        "creationDate": "2014-08-01T16:38:13.958-05:00",
                        "using": true,
                        "alertState": 0,
                        "alertStates": [
                            "OK"
                        ],
                        "percentComplete": 100,
                        "storePointId": 1,
                        "storePointName": "Default",
                        "serverId": 3,
                        "serverName": "CrashPlan Server",
                        "serverHostName": "http://alpha:4280",
                        "isProvider": false
                    }
                ]
            },
            {
                "computerId": 11,
                "name": "Beta",
                "guid": "631663249095393537",
                "type": "COMPUTER",
                "status": "Active",
                "active": true,
                "blocked": false,
                "alertState": 0,
                "alertStates": [
                    "OK"
                ],
                "userId": 3,
                "orgId": 2,
                "parentComputerId": null,
                "lastConnected": "2014-08-07T15:26:14.212-05:00",
                "osName": "Linux",
                "osVersion": "3.2.0-4-686-pae",
                "osArch": "i386",
                "address": "172.16.195.139:4242",
                "remoteAddress": "172.16.195.139",
                "javaVersion": "1.6.0_27",
                "modelInfo": null,
                "timeZone": "US/Central",
                "version": 1375333203614,
                "productVersion": "3.6.1.4",
                "creationDate": "2014-08-07T15:26:12.274-05:00",
                "modificationDate": "2014-08-07T15:26:16.615-05:00",
                "loginDate": "2014-08-07T15:26:14.309-05:00",
                "backupUsage": [
                    {
                        "targetComputerId": 2,
                        "targetComputerParentId": null,
                        "targetComputerGuid": "647903643760066817",
                        "targetComputerName": "CrashPlan Server",
                        "targetComputerOsName": null,
                        "targetComputerType": "SERVER",
                        "selectedFiles": 588,
                        "selectedBytes": 798675763,
                        "todoFiles": 588,
                        "todoBytes": 798675763,
                        "archiveBytes": 357,
                        "billableBytes": 357,
                        "sendRateAverage": 92047,
                        "completionRateAverage": 0,
                        "lastBackup": "2014-08-07T15:27:08.191-05:00",
                        "lastCompletedBackup": null,
                        "lastConnected": "2014-08-07T15:29:45.648-05:00",
                        "lastMaintenanceDate": "2014-08-07T15:27:05.388-05:00",
                        "lastCompactDate": null,
                        "modificationDate": "2014-08-07T15:29:45.648-05:00",
                        "creationDate": "2014-08-07T15:27:05.389-05:00",
                        "using": true,
                        "alertState": 0,
                        "alertStates": [
                            "OK"
                        ],
                        "percentComplete": 0,
                        "storePointId": 1,
                        "storePointName": "Default",
                        "serverId": 3,
                        "serverName": "CrashPlan Server",
                        "serverHostName": "http://alpha:4280",
                        "isProvider": false
                    }
                ]
            }
        ]
    }
}

Number of devices on CrashPlan app version x

One common use of the CrashPlan API is to identify how many devices run a specific version number. This can be useful after client upgrade to confirm that the devices upgraded automatically. The example below uses the Computer resource, limits the output to only active devices with active=true, and exports the data. Grep then filters the output to count the number of instances of the version string ,8.7.0,.


curl "https://console.us1.crashplan.com/api/v1/Computer?export=csv&active=true" -H 'Authorization: Bearer <auth_token>' | grep -c ,8.7.0,

The command outputs the total number of active devices (up to 999) running version 3.6.3.

Note that the Computer resource includes both mobile devices and computers.

CrashPlan app versions other than x

If you have a large CrashPlan environment, (more than 1000 devices), working with long lists of information via standard output (stdout) can be cumbersome. You can export the list to a CSV file and then manipulate the data with utilities such as awk or Microsoft Excel. Awk is a text-processing programming language and is a useful tool for manipulating text files.

The example below uses curl, grep, and awk to display a list of active devices reporting a version other than the current version (in this example, the current version is 3.6.3). This can be a useful script following a large upgrade to see which client versions exist in the environment.

The example uses the Computer resource. Output is limited to active devices (active=true) and then exported. The exported output contains all computer resource properties for active devices reporting a current version other than 3.6.3. We use grep to remove the header row and then redirect the output to a text file named “devices.txt”. We then use awk to process the text file and display only the lines that do not contain the version number 8.7.0.


curl "https://console.us1.crashplan.com/api/v1/Computer?export=csv&active=true" -H 'Authorization: Bearer <auth_token>' | python3 -mjson.tool | grep ,, > devices.txt awk -F "," '$18 != "8.7.0" {print $18}' devices.txt

Sample output:

8.7.1
8.6.1
8.6.0

Users

Security audit for admin access

As a CrashPlan environment grows over time, a large number of administrators may be involved with daily management. The following example uses the Users resource to list all of the active users with the assigned roleId=org-admin, which corresponds to Org Admin. The output is then filtered with the grep utility to show only rows containing the usernames.


curl "https://console.us1.crashplan.com/api/v1/User?active=true&pgSize=999&roleId=org-admin&incRoles=true" -H 'Authorization: Bearer <auth_token>' | python3 -mjson.tool | grep -w username

Sample output:

"username": "michelle.lee@example.com",
      "username": "chris.smith@example.com",
      "username": "joe.johnson@example.com",

Move a user

You can move a user to a different organization by passing parameters to the CrashPlan API. Here the user account with userID=307 is moved to the organization with parentOrgId=71.


curl -v -H "Content-Type: application/json" -X POST -d '{"userId":307,"parentOrgId":71}' https://console.us1.crashplan.com/api/v1/UserMoveProcess -H 'Authorization: Bearer <auth_token>'

Update a user's backup disk quota

You can use the Users resource to update the total amount of storage a user is allowed to consume across all devices. Here the user userId=80 is updated to have a 30 GB quota.


curl -X PUT -H "Content-Type: application/json" -d '{"quotaInBytes":30000000000}' https://console.us1.crashplan.com/api/v1/User/80 -H 'Authorization: Bearer <auth_token>'
 
Was this article helpful?
0 out of 0 found this helpful

Articles in this section