You can manage job schedules using these methods. Currently, the only type of job is a scheduled backup.
| Schedule Management Methods | URL |
|---|---|
| List jobs scheduled to run in OpsCenter. | GET /{cluster_id}/job-schedules |
| Get the description of a scheduled job. | GET /{cluster_id}/job-schedules/{schedule_id} |
| Schedule a job. | POST /{cluster_id}/job-schedules |
| Modify a scheduled job. | PUT /{cluster_id}/job-schedules/{schedule_id} |
| Delete a scheduled job. | DELETE /{cluster_id}/job-schedules/{schedule_id} |
Using these methods, get the status of and start backups across registered clusters.
| Backup Management Methods | URL |
|---|---|
| List backups in the cluster. | GET /{cluster_id}/backups |
| List backups for a keyspace in the cluster. | GET /{cluster_id}/backups/{ks_name} |
| Run a backup. | POST /{cluster_id}/backups/run |
Retrieve a list of jobs scheduled to run in OpsCenter. Currently the only type of job is a scheduled backup.
| Path arguments: | cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs. |
|---|---|
| Responses: | 201 -- Schedule created successfully |
Returns a list of JobSchedule objects.
{
"first_run_date": <value>,
"first_run_time": <value>,
"timezone": <value>,
"interval": <value>,
"interval_unit": <value>,
"job_params": {<type>: <value>, <name>: <value>, ...},
"id": <value>,
"last_run": <value>
}
This table describes the property values of a JobSchedule object:
| Property | Type | Description of Values |
|---|---|---|
| first_run_date | String | A date in YYYY-MM-DD format the date for running the job. |
| first_run_time | String | A time in hh:mm:ss format specifying the time to begin running the job. |
| timezone | String | The time zone, listed in the OpsCenter /meta/timezones directory, for the job schedule. For example, GMT, US/Central, US/Pacific, and US/Eastern. |
| interval | Int | The number of times a job runs during an interval_unit. For example, an interval of 2 and an interval_unit of weeks runs a job every two weeks. |
| interval_unit | String | The unit of time of an interval. Values are minutes, hours, days, or weeks. |
| job_params | -- | An object that describes the job. Only the type field is required and its value is currently limited to backup. |
| id | String | A unique ID that references a job schedule. Use only for retrieving a job schedule. |
| last_run | String | The date and time of the last successful run. Use only for retrieving a job schedule. |
Example:
curl
http://127.0.0.1:8888/Test_Cluster/job-schedules
-X GET
Output:
[
{
"first_run_date": "2012-04-19",
"first_run_time": "18:00:00",
"id": "19119720-115a-4f2c-862f-e10e1fb90eed",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"last_run": "",
"next_run": "2012-04-19 18:00:00 GMT",
"timezone": "GMT"
},
...
]
Get the description of a specific scheduled job.
| Path arguments: |
|
|---|
Returns a JobSchedule object
Example:
curl
http://127.0.0.1:8888/Test_Cluster/job-schedules/19119720-115a-4f2c-862f-e10e1fb90eed
-X GET
Output:
{
"first_run_date": "2012-04-19",
"first_run_time": "18:00:00",
"id": "19119720-115a-4f2c-862f-e10e1fb90eed",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"last_run": "",
"next_run": "2012-04-19 18:00:00 GMT",
"timezone": "GMT"
}
Create a new scheduled job. You can create a scheduled job to run one time in the future by specifing an interval=-1 and interval_unit=null.
| Path arguments: | cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs. |
|---|---|
| Body : | A dictionary in the format of JobSchedule describing the scheduled job to create. |
| Responses: | 201 -- Job schedule created successfully |
Returns the ID of the newly created job.
Example
curl
http://127.0.0.1:8888/Test_Cluster/job-schedules/
-X POST
-d
'{
"first_run_date": "2012-05-03",
"first_run_time": "18:00:00",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"timezone": "GMT"
}'
Output:
"905391b7-1920-486d-a633-282f22dce604"
Update an existing scheduled job.
| Path arguments: |
|
|---|---|
| Body : | A dictionary in the format of JobSchedule describing the scheduled job to create. |
| Responses: | 200 -- Schedule updated successfully |
Returns null.
Example
curl
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22dce604
-X PUT
-d
'{
"first_run_date": "2012-05-05",
"first_run_time": "19:00:00"
}'
Delete an existing scheduled job.
| Path arguments: |
|
|---|---|
| Responses: | 200 -- Schedule deleted successfully |
Returns null.
Example
curl
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22dce604
-X DELETE
Get a list of existing snapshots in the cluster.
| Path arguments: | cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs. |
|---|
Returns a dictionary describing existing snapshots in the cluster. Each key in the dictionary is the ID of the snapshot and each value is a dictionary describing the snapshot.
Example
curl http://127.0.0.1:8888/Test_Cluster/backups
-X GET
Output:
{
"opscenter_adhoc_2012-04-19-17-41-12-UTC": {
"id": "adhoc",
"keyspaces": {
"OpsCenter": {
"nodes": [
"127.0.0.1"
],
"size": 23180
},
"system": {
"nodes": [
"127.0.0.1"
],
"size": 48961
},
"test": {
"nodes": [
"127.0.0.1"
],
"size": 4543
}
},
"time": 1334857272
}
}
Get a list of existing snapshots for a specific keyspace in the cluster.
| Path arguments: |
|
|---|
Returns a dictionary describing existing snapshots in the cluster. Each key in the dictionary is the ID of the snapshot and each value is a dictionary describing the snapshot.
Example
curl http://127.0.0.1:8888/Test_Cluster/backups/movies_ks
-X GET
Output:
{
"opscenter_adhoc_2012-04-18-15-06-47-UTC": {
"id": "adhoc",
"keyspaces": {
"movies_ks": {
"nodes": [
"10.11.12.150",
"10.11.12.152"
],
"size": 14833
}
},
"time": 1334761607
}
Run a one time backup immediately.
| Path arguments: | cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs. |
|---|---|
| Body : | A json dictionary containing the options to use for running this one-time backup. |
Returns true to indicate a successful snapshot.
Example
Start a backup of the test keyspace on nodes 10.11.12.150 and 10.11.12.152 to run immediately.
curl http://127.0.0.1:8888/Test_Cluster/backups/run
-X POST
-d
'{"keyspaces":
{"test":
{"nodes": ["10.11.12.150", "10.11.12.152"], "size": 29644}
}
}'
Output:
The first true response indicates that the snapshot was successful for the specified node.
[
true,
[
null,
"10.11.12.150"
]
],
[
true,
[
null,
"10.11.12.152"
]
]
Note: You can schedule a one-time backup in the future using the POST /{cluster_id}/job-schedules. Specify an interval=-1 and interval_unit=null.