Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
res0nat0r / restore.py
Created May 1, 2019 21:29
Restore s3 objects from glacier with boto
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('glacier-bucket')
for obj_sum in bucket.objects.all():
obj = s3.Object(obj_sum.bucket_name, obj_sum.key)
if obj.storage_class == 'GLACIER':
# Try to restore the object if the storage class is glacier and
# the object does not have a completed or ongoing restoration
# request.