繁体   English   中英

无法下载 aws s3 冰川对象

[英]Unable to download aws s3 glacier objects

我试图将所有文件从我的 S3 存储桶复制到 VM 中的本地文件夹,但出现以下错误:

warning: Skipping file s3://bucket/object. Object is of storage class GLACIER.
Unable to perform download operations on GLACIER objects. You must restore the
object to be able to perform the operation. See aws s3 download help for
additional parameter options to ignore or force these transfers.

冰川错误

要将文件从我的 S3 存储桶复制到本地文件夹,我使用了以下命令:

aws s3 cp s3://${s3Location} ${localDumpPath}

在哪里:

  • ${s3Location} = 我的 s3 位置和
  • ${localDumpPath} = 我的本地文件夹路径

我需要更改什么才能成功复制?

我使用以下命令解决了这个问题:

aws s3 cp s3://${s3Location} ${localDumpPath} --storage-class STANDARD --recursive --force-glacier-transfer

You can also refer the below link to get details of how to restore an S3 object from the Amazon S3 Glacier storage class using the AWS CLI: Restore S3 object from the Amazon Glacier storage class

问题:您正在尝试复制 aws s3 object 但存储类型是冰川并且您收到以下错误:

warning: Skipping file s3://<SomePathToS3Object> Object is of storage class GLACIER.
Unable to perform download operations on GLACIER objects.
You must restore the object to be able to perform the operation.
See aws s3 download help for additional parameter options to ignore or force these transfers.

说明: Amazon S3 Glacier是一种安全、耐用且成本极低的云存储服务,用于数据归档和长期备份。 当您需要使用执行恢复请求的文件时,您需要支付检索价格,几个小时后 object 将启用并准备就绪。 当这些数据很少被使用时,此功能通常使用公司来归档文件/日志/数据库/备份。

解决方案:为了获取冰川文件,您需要发起恢复请求,监控恢复请求的状态,一旦完成更改存储 class(标准)的 object 并复制它。 您可以使用aws 参考

//Initate restore request:
$ aws s3api restore-object --bucket examplebucket --key dir1/example.obj \
--restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Standard"}}'

//monitor status:
$ aws s3api head-object --bucket examplebucket --key dir1/example.obj

// output example - restore in progress
{
    "Restore": "ongoing-request=\"true\"",
    ...
    "StorageClass": "GLACIER",
    "Metadata": {}
}

// output example - restore completed
 {
    "Restore": "ongoing-request=\"false\", expiry-date=\"Sun, 1 January 2000 00:00:00 GMT\"",
    ...
    "StorageClass": "GLACIER",
    "Metadata": {}
}

$ aws s3 cp s3://examplebucket/dir1/ ~/Downloads \
--storage-class STANDARD --recursive --force-glacier-transfer

你写道你需要“将所有文件复制”到本地文件夹,假设你想递归复制文件。

由于文件保存在 Glacier 存储 class 中,您需要先从 Glacier 存档中恢复它们,然后才能将它们复制到本地文件夹,即让文件在指定的天数内可供检索。 恢复完成后,您可以复制指定--force-glacier-transfer参数的文件,直到您以天为单位指定的期限到期。

除非您将文件存储在“S3 Glacier Instant Retrieval”存储 class 中,否则您应该首先恢复文件(使它们可供检索),这样--force-glacier-transfer选项就不会失败。 因此,在https://stackoverflow.com/a/62651252/6910868提出的解决方案不适用于“S3 Glacier Deep Archive”存储 class,为此您必须明确发出restore-object命令并等待其完成之前您可以将文件复制到本地文件夹。

但是, aws s3api restore-object只恢复一个文件,不支持递归恢复。 https://stackoverflow.com/a/65925266/6910868指定的解决方案不适用于递归目录,或者当您有多个文件时,您希望仅指定文件夹而不是一一列出所有文件。

作为替代方案,您可以将对象的存储 class 更改为 Amazon S3 标准,而不是通过使文件可供检索来恢复文件。 为此,您可以通过覆盖现有文件或将文件从一个 S3 位置复制到另一个 S3 位置来复制 S3 中的文件。 在每种情况下,您都应该指定正确的目标存储 class。

如果您只需要从 Glacier 存储 class 检索递归文件而不更改存储 class 或在 S3 中制作额外的副本,您可以使用Perl 脚本递归列出文件,然后分别从 Glacier 恢复它们。 此脚本不仅可用于使用指定的还原层启动还原,还可用于监视该过程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM