Created
September 11, 2015 13:58
-
-
Save coderberry/b8e5ba15cab463a4f606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'typhoeus' | |
require 'json' | |
NAME = 'MY_APP_NAME' | |
TOKEN = File.read("~/.cloud66/token") | |
STACK_ID = 'MY_CLOUD66_STACK_ID' | |
# Get backups | |
request = Typhoeus::Request.new("https://app.cloud66.com/api/3/stacks/#{STACK_ID}/backups.json", method: :get, headers: { Authorization: "Bearer #{TOKEN}" }) | |
request.run | |
response = request.response | |
resp = JSON.parse(response.body) | |
backup_id = resp['response'][0]['id'] | |
# Get backup files | |
request = Typhoeus::Request.new("https://app.cloud66.com/api/3/stacks/#{STACK_ID}/backups/#{backup_id}/files.json", method: :get, headers: { Authorization: "Bearer #{TOKEN}" }) | |
request.run | |
response = request.response | |
resp = JSON.parse(response.body) | |
file_id = resp['response'][0]['id'] | |
# Get backup file url | |
request = Typhoeus::Request.new("https://app.cloud66.com/api/3/stacks/#{STACK_ID}/backups/#{backup_id}/files/#{file_id}.json", method: :get, headers: { Authorization: "Bearer #{TOKEN}" }) | |
request.run | |
response = request.response | |
resp = JSON.parse(response.body) | |
public_url = resp['response']['public_url'] | |
`cd backups; wget #{public_url}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment