Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

Manual restores via Rackspace Cloud Backup API

Manual restores via the API can come in handy when dealing with large directories that contain enough files to cause the UI to timeout or just spin. Manual restores can be a pain in the rear due to having to run multiple API calls so will not be recommended for all restores, just the ones that cause issues with the UI which are mainly caused by the number of files or directories needing to be looked up.
To start, you can find the documentation for all the Rackspace product APIs, including Cloud Backup at: http://docs.rackspace.com
The first part of creating a restore from the API is to locate a few account specific information. We will assume that you know the following information:
  • DDI = This is your account number
  • Region = Datacenter you are hosting in (DFW, ORD, IAD, LON, HKG, SYD)
  • Server_ID = The unique identifier of the host server where the Cloud Backup agent is running (SliceID or UUID)
  • Token = String of characters that uniquely identifies that your user has been authenticated.
  • Username = Username you would use to log into your Rackspace Control panel at mycloud.rackspace.com
If you do not know your API token, you can use the API call below to authenticate against and receive the API token. This token will be valid for up to 24 hours and should not be needed to be regenerated for every API call. If you do not know your API key, you can obtain this within the Rackspace Cloud control panel by clicking your username at the top right, then clicking on account settings.
Please note that any variable notated with ${VARIABLE_NAME} will need to be substituted with the correct value.

Generating API token:

curl -s https://identity.api.rackspacecloud.com/v2.0/tokens -X POST -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"${USERNAME}","apiKey":"${APIKEY}"}}}' -H "Content-type: application/json" | python -m json.tool
Note: You will specifically be looking for the section called "token" and will need to save the "id" defined within the token section. This will look like a long, random string of characters. This "id" will be the "token" for the remaining API calls. Once you have generated the API token, we can then go ahead and wake up the backup clients on the account.

Wake up agents:

 
Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/user/wakeupagents -XPOST -D -
Note: There is no values that you need to save for this API call, this is only to wake up the clients in preparation to setting up the restore itself. Once you have issue the wakeup call, you can proceed with getting the server information needed to prepare the remaining API calls.

List agents by server:

Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/agent/server/${SERVER_ID} -XGET -H "Content-Type: application/json" | python -mjson.tool
Note: You will need to save the value defined as "MachineAgentId" for the next API call. This will turn into the ${AGENT_ID} in the "Get all backup configs for agent" API call.

Get all backup configs for agent:

Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/backup-configuration/system/${AGENT_ID} -XGET -H "Content-Type: application/json"  |python -mjson.tool\
Note: You will need to save the value defined as "BackupConfigurationId" for the next API call. This will turn into the ${BACKUP_CONFIGURATION_ID} in the "List completed backups" API call.

List completed backups:

Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/backup/completed/${BACKUP_CONFIGURATION_ID} -XGET -H "Content-Type: application/json"  |python -mjson.tool
Note: You will need to save the value defined as "BackupId" for the next API call. This will turn into the ${BACKUP_ID} in the "Create restore config" API call.

Create restore config:

Link to documentation:
*** Please carefully review the documentation in the link above for this API call. This API call has multiple values, and be destructive if not issued correctly. There will be definitions for the for each required and optional value for this API call in the link.
Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/restore -XPUT -H "Content-Type: application/json" -d '{"BackupId":${BACKUP_ID},"BackupMachineId":${BACKUP_MACHINE_ID},"DestinationMachineId":${DESTINATION_MACHINE_ID},"DestinationPath":${DESTINATION_PATH},"BackupDataCenter":${REGION},"OverwriteFiles":true' |python -m json.tool
Note: You will need to save the value defined as "RestoreId" for the next API call. This will turn into the ${PARENT_ID} in the "Add files to restore config" API call.

Add files to restore config:

**** Please carefully review the documentation in the link above for this API call. This API call has multiple values, and be destructive if not issued correctly. There will be definitions for the for each required and optional value for this API call in the link.
Mock API call:
curl -sH "X-AUth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/restore/files -H "Content-Type: application/json" -d '{"FilePath":"${RESTORE_DIR}","Filter":"1","ParentId":${RESTORE_ID},"FileItemType":"0"}' -XPUT |python -m json.tool
Note: This operation does not return a response body.

Verify restore:

Note: Make sure that all the values return correctly, this is the last chance to check and change any data before submitting the actual API call to start the restore.

Start restore:

Mock API call:
curl -sH "X-Auth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/restore/action-requested -H "Content-Type: application/json" -d  '{"Action":"StartManual","Id":${RESTORE_ID}}' -D -
Note: This operation does not return a response body.

Check restore status:

Mock API call:
curl -sH "X-Auth-Token: ${TOKEN}" https://${REGION}.backup.api.rackspacecloud.com/v1.0/${DDI}/restore/report/${RESTORE_ID} |python -mjson.tool
Note: You may need to check back multiple times until you get a status change.