【问题标题】:Amazon S3 object restore from GLACIER not working with Python boto3从 GLACIER 还原的 Amazon S3 对象无法使用 Python boto3
【发布时间】:2021-11-12 17:35:04
【问题描述】:

尝试使用以下代码从 GLACIER 恢复 Amazon S3 对象。

import boto3

s3 = boto3.resource('s3', verify=False)

bucket_name = r"my-source-bucket"
bucket = s3.Bucket(bucket_name)
key ="glacier_file2.txt"

try:
    bucket.meta.client.restore_object(Bucket=bucket_name, Key=key, RestoreRequest={'Days': 1, 'GlacierJobParameters': {'Tier': 'Expedited'}})
except Exception as e:
    print({"Problem Restoring": str(e)})

代码已成功提交,但该对象仍显示为 AWS 控制台中的 GLACIER 以及我什至几天后使用 boto3 查询它时。如果我运行以下代码,我发现它仍然显示 GLACIER。

key = s3.Object(bucket_name,key)
print (key.storage_class)
print (key.restore)

>>>>GLACIER
>>>>ongoing-request="false", expiry-date="Sun, 19 Sep 2021 00:00:00 GMT"

当我尝试在 AWS 控制台中执行相同的操作时,我看到它说它在 GLACIER 中并且恢复已完成?

有人有什么见解吗?恢复后,我实际上可以下载该文件,这告诉我它实际上不在 GLACIER 中,尽管它说它在浏览器中,也在 boto3 中。还原后报告存储类的方式有问题吗?

编辑我应该指出我正在进行快速恢复,只需要几分钟。

【问题讨论】:

    标签: python python-3.x amazon-web-services amazon-s3 boto3


    【解决方案1】:

    在进行了更多研究之后,“恢复”似乎不是人们所期望的。一旦一个对象进入 GLACIER,就没有回头路了,除了“暂时”恢复它(就像我在上面所做的那样)然后覆盖它。例如,我在恢复 glacier_file2.txt 后能够运行此命令

    aws s3 cp s3://my-source-bucket/glacier_file2.txt s3://my-source-bucket/glacier_file2.txt --force-glacier-transfer --storage-class STANDARD
    

    https://newbedev.com/how-do-i-restore-from-aws-glacier-back-to-s3-permanently

    如果我没有触发临时 GLACIER 恢复,这将不起作用。

    【讨论】:

      猜你喜欢
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      • 1970-01-01
      • 2016-03-15
      • 1970-01-01
      • 2019-07-01
      相关资源
      最近更新 更多