The Python Oracle

Using Boto to tell when a file has successfully been uploaded to Glacier

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Using Boto To Tell When A File Has Successfully Been Uploaded To Glacier
01:49 Accepted Answer Score 5
02:27 Thank you

--

Full question
https://stackoverflow.com/questions/1703...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #amazonwebservices #boto #amazonglacier

#avk47



ACCEPTED ANSWER

Score 5


Take a look at this Boto and Glacier guide, you can either poll it manually from boto or you can set up Amazon Simple Notification Service to notify you when the job is done.

archive_id = vault.upload_archive("mybackup.tgz")
retrieve_job = vault.retrieve_archive(archive_id)

# if the job is in progress
job_id = retrieve_job.id
retrieve_job = vault.get_job(job_id)

if retrieve_job.completed:
    job.download_to_file("mybackup.tgz")

You can use boto's set_vault_notifications function set the SNS notifications.

notification_config = {'SNSTopic': 'my_notification_topic',
                       'Events': ['ArchiveRetrievalCompleted',
                                  'InventoryRetrievalCompleted']}
vault.set_vault_notifications(vault, notification_config)

Here is an extensive example of waiting for an upload by setting up SNS notification subscriptions to SQS queue service.