Reputation: 91
I'm actually using python boto to store data on my glacier's vault and launch retrieve jov and inventory job.
This works quite well.
But i didn't find any example about the method to use to download an archive from glacier?
I had launch retrieve jov and inventory job and got request id 4 hours later etc, but howto grab my archive by using boto ?
Thanks for your help !
Upvotes: 6
Views: 1724
Reputation: 711
Assuming that your retrieval job has finished and you have the job ID, the following is a minimal example for downloading with boto.
import boto.glacier
# Constants
ACCESS_KEY_ID = '<key>'
SECRET_ACCESS_KEY = '<secret key>'
VAULT_NAME = 'myVault'
REGION_NAME = 'us-east-2'
JOB_ID = '<job-id>'
file_name = 'glacier.zip'
layer2 = boto.connect_glacier(aws_access_key_id = ACCESS_KEY_ID,
aws_secret_access_key = SECRET_ACCESS_KEY,
region_name = REGION_NAME)
vault = layer2.get_vault(VAULT_NAME)
job = vault.get_job(JOB_ID)
if job.completed:
print(f'Downloading to {file_name}')
job.download_to_file(file_name)
else:
print('The specified job has not completed, try again later.')
See also Downloading a large archive from AWS Glacier using Boto
Upvotes: 0
Reputation: 45846
To retrieve your inventory, you could do something like this:
import boto.glacier
c = boto.glacier.connect_to_region('us-east-1')
vault = c.get_vault('myvault')
job = vault.get_job('<your job id>')
response = job.get_output()
print response.read()
It's a bit confusing because the call to get_output() returns a dict-like object but that object has a read method that you can use to retrieve the data associated with the response.
Upvotes: 5