AWS S3 CLI 命令无法将 GLACIER 对象从 S3 下载到 Linux

问题描述 投票:0回答:1

我正在 Linux 中使用 aws-cli/1.22.97 并尝试从 S3 存储桶下载单个文件,其中包含存储类 GLACIER 和 STANDARD 的对象(文件)。

正如预期的那样,我可以使用

aws s3 cp s3://bucket-name/pre_1/pre_2/file_name.ext .
下载存储类别 STANDARD 的文件,但是当我尝试下载存储类别 GLACIER 的单个文件时,它失败了。

我尝试使用

aws s3 cp s3://bucket-name/pre_1/pre_2/file_name.ext . --storage-class STANDARD --force-glacier-transfer
下载存储类 GLACIER 的单个文件,结果出现以下错误:

download failed: s3://bucket-name/pre_1/pre_2/file_name.ext to ./file_name.ext An error occurred (InvalidObjectState) when calling the GetObject operation: The operation is not valid for the object's storage class 

我还尝试了同一命令的其他变体,但出现如下错误:

aws s3 cp s3://bucket-name/pre_1/pre_2/file_name.ext . --storage-class GLACIER --force-glacier-transfer
download failed: s3://bucket-name/pre_1/pre_2/file_name.ext to ./file_name.ext An error occurred (InvalidObjectState) when calling the GetObject operation: The operation is not valid for the object's storage class

aws s3 cp s3://bucket-name/pre_1/pre_2/file_name.ext . --storage-class GLACIER
warning: Skipping file s3://bucket-name/pre_1/pre_2/file_name.ext. 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.

aws s3 cp s3://bucket-name/pre_1/pre_2/file_name.ext . --storage-class STANDARD
warning: Skipping file s3://bucket-name/pre_1/pre_2/file_name.ext. 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.

我在这里阅读了一些帖子,例如this,其中指出对于单个文件下载,这种格式的 cp 命令应该可以工作,但对我来说它不起作用。我不知道 GLACIER 是“灵活检索”类型还是“深度存档”存储类别。

有没有办法使用 AWS CLI 下载存储类 GLACIER 的单个文件,而无需运行两个命令?

  1. 先恢复并等待恢复完成
  2. 然后运行 cp 作为第二个命令?

我正在寻找一个可以从 CLI 运行的命令。

amazon-s3 aws-cli amazon-glacier
1个回答
0
投票

有没有办法使用 AWS CLI 下载存储类 GLACIER 的单个文件,而无需运行两个命令?

不,无法使用 AWS CLI 来执行此操作。

Glacier 是一种特殊的存储类别,在通常意义上并不能立即可用。

AWS 没有公开披露其背后的技术,但人们一直猜测它是磁带驱动器、蓝光光盘或磁驱动器,只是放在仓库的机架上,没有连接到任何东西。人们普遍认为,冰川恢复需要使用体力劳动来物理移动数据介质。亚马逊是一家以能够高效执行此类操作而闻名的公司。这就是(最可能的)原因:冰川数据的存储成本非常低,但下载成本却很高。

要从 Glacier 复制某些内容,您需要等待它在 S3 上可用(即从冷时所处的任何介质中恢复)。这可能需要几个小时。

从技术上讲,将此流程实现为单个命令并非不可能,但 AWS API 调用通常的方式是打开 HTTPS 流、发送请求并等待响应。它们专为只需要几秒钟而不是几个小时的事情而设计。

正如评论中提到的,使用异步事件或轮询可以更好地实现此流程。

© www.soinside.com 2019 - 2024. All rights reserved.