With these methods, you can schedule periodic snapshots, run snapshots immediately, view the snapshots that currently exist in the cluster, and restore from a snapshot.
| Managing Snapshot Job Schedules | |
| 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} |
| Managing Snapshots | |
| List snapshots in the cluster. | GET /{cluster_id}/backups |
| List snapshots for a keyspace in the cluster. | GET /{cluster_id}/backups/{ks_name} |
| Run a snapshot immediately. | POST /{cluster_id}/backups/run |
| Restoring from Snapshots | |
| Restore all data from a snapshot. | POST /{cluster_id}/backups/restore/{tag} |
| Restore a specific keyspace from a snapshot. | POST /{cluster_id}/backups/restore/{tag}/{ksname} |
| Restore a specific column family from a snapshot. | POST /{cluster_id}/backups/restore/{tag}/{ksname}/{cfname} |
A job schedule describes an action that OpsCenter will run periodically. Currently, the only type of scheduled job available is a snapshot job.
A job schedule has the following form:
{
"first_run_date": FIRST_RUN_DATE,
"first_run_time": FIRST_RUN_TIME,
"timezone": TIMEZONE,
"interval": INTERVAL,
"interval_unit": INTERVAL_UNIT
"job_params": JOB_PARAMS,
"id": ID,
"next_run": NEXT_RUN,
"last_run": LAST_RUN
}
| Data: |
|
|---|
A JSON dictionary that describes a backup type of Job Schedule. This should be used as the job_params field in the Job Schedule.
{
"type": "backup",
"keyspaces": KEYSPACES,
"cleanup_age": CLEANUP_AGE,
"cleanup_age_unit": CLEANUP_AGE_UNIT,
"pre_snapshot_script": PRE_SNAPSHOT_SCRIPT,
"post_snapshot_script": POST_SNAPSHOT_SCRIPT
}
| Data: |
|
|---|
Retrieve a list of jobs scheduled to run in OpsCenter. Currently the only type of job is a scheduled snapshot.
| Path arguments: | cluster_id -- A Cluster Config ID. |
|---|
Returns a list of Job Schedule objects.
Example:
curl http://127.0.0.1:8888/Test_Cluster/job-schedules
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": "2012-04-20 18:00:00 GMT",
"next_run": "2012-04-21 18:00:00 GMT",
"timezone": "GMT"
},
...
]
Get the description of a scheduled job.
| Path arguments: |
|
|---|
Returns a Job Schedule object.
Create a new scheduled job. You can create a scheduled job to run one time in the future by specifying an interval of -1 and interval_unit of null.
| Path arguments: | cluster_id -- A Cluster Config ID. |
|---|---|
| Body : | A dictionary in the format of a Job Schedule describing the scheduled job to create. The id, last_run, and next_run fields should be omitted. |
| Responses: | 201 -- Job schedule created successfully |
Returns the ID of the newly created job.
Example
curl -X POST
http://127.0.0.1:8888/Test_Cluster/job-schedules/
-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 a scheduled job.
| Path arguments: |
|
|---|---|
| Body : | A dictionary with fields from Job Schedule that you would like to update. |
| Responses: | 200 -- Schedule updated successfully |
Returns null.
Example
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22dce604
-d
'{
"interval": "12",
"interval_unit": "hours"
}'
Delete a scheduled job.
| Path arguments: |
|
|---|---|
| Responses: | 200 -- Schedule deleted successfully |
Returns null.
Example
curl -X DELETE
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22dce604
Get a list of snapshots that exist in the cluster.
| Path arguments: | cluster_id -- A Cluster Config ID. |
|---|---|
| Opt. params: | match -- A Job Schedule ID to limit snapshots to those created by a particular snapshot schedule. |
Returns a dictionary describing 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
Output:
{
"opscenter_adhoc_2012-04-19-17-41-12-UTC": {
"id": "adhoc",
"keyspaces": {
"OpsCenter": {
"cfs": [
"events",
"events_timeline",
"rollups60",
...
],
"nodes": [
"127.0.0.1"
],
"size": 23180
},
"system": {
"cfs": [
"LocationInfo",
"Schema",
...
],
"nodes": [
"127.0.0.1"
],
"size": 48961
},
"test": {
"cfs": [
"cf1",
"cf2"
],
"nodes": [
"127.0.0.1"
],
"size": 4543
}
},
"time": 1334857272
}
}
Get a list of snapshots that exist for a keyspace in the cluster.
| Path arguments: |
|
|---|
Returns data in the same format as GET /{cluster_id}/backups.
Run a one time backup immediately.
| Path arguments: | cluster_id -- A Cluster Config ID. |
|---|---|
| Body : | A JSON dictionary containing the options to use for running this one-time snapshot. |
Returns true to indicate a successful snapshot.
Example
Start a snapshot of two keyspaces immediately.
curl -X POST
http://127.0.0.1:8888/Test_Cluster/backups/run
-d '{"keyspaces": ["Keyspace1", "Keyspace2"]}'
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 snapshot in the future using the POST /{cluster_id}/job-schedules. Specify an interval=-1 and interval_unit=null.
Restore all data from a snapshot.
| Path arguments: |
|
|---|---|
| Body : | A JSON dictionary of options, including:
|
Returns a Request ID.
Example
SNAPSHOT='opscenter_4a269167-96c1-40c7-84b7-b070c6bcd0cd_2012-06-07-18-00-00-UTC'
curl -X POST
http://192.168.1.1:8888/Test_Cluster/backups/restore/$SNAPSHOT
-d '{
"throttle": 10,
"excluded-nodes": [
"192.168.100.7"
],
"keyspaces": {
"Keyspace1": {
"column-families: ["users", "dates"],
"truncate": true
},
"OpsCenter": {
"truncate": false
}
},
}'
Output:
"fee2232c-48ac-11e2-b1b9-e0b9a54a6d93"
Restore a keyspace from a snapshot.
| Path arguments: |
|
|---|---|
| Body : | A JSON dictionary of options, including:
|
Returns a Request ID.
Example
SNAPSHOT='opscenter_4a269167-96c1-40c7-84b7-b070c6bcd0cd_2012-06-07-18-00-00-UTC'
curl -X POST
http://192.168.1.1:8888/Test_Cluster/backups/restore/$SNAPSHOT/Keyspace1
-d '{
"throttle": 10,
"excluded-nodes": [
"192.168.100.7"
],
"column-families: ["users", "dates"],
"truncate": true
}'
Output:
"fee2232c-48ac-11e2-b1b9-e0b9a54a6d93"
Restore a column family from a snapshot.
| Path arguments: |
|
|---|---|
| Body : | A JSON dictionary of options, including:
|
Returns a Request ID.
Example
SNAPSHOT='opscenter_4a269167-96c1-40c7-84b7-b070c6bcd0cd_2012-06-07-18-00-00-UTC'
curl -X POST
http://192.168.1.1:8888/Test_Cluster/backups/restore/$SNAPSHOT/Keyspace1/users
-d '{
"throttle": 10,
"excluded-nodes": [
"192.168.100.7"
],
"truncate": true
}'
Output:
"fee2232c-48ac-11e2-b1b9-e0b9a54a6d93"