简体   繁体   English

无法下载 aws s3 冰川对象

[英]Unable to download aws s3 glacier objects

I was trying to copy all the files from my S3 bucket to a local folder in VM and I am getting the following error:我试图将所有文件从我的 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.

冰川错误

To copy files from my S3 bucket to local folder I used the following command:要将文件从我的 S3 存储桶复制到本地文件夹,我使用了以下命令:

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

Where:在哪里:

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

What do I need to change to be able to copy successfully?我需要更改什么才能成功复制?

I fixed the issue by using the following command:我使用以下命令解决了这个问题:

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 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

The Problem : you are trying to copy an aws s3 object but the storage type is glacier and you got the following error:问题:您正在尝试复制 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.

Explanation : Amazon S3 Glacier is a secure, durable, and extremely low-cost cloud storage service for data archiving and long-term backup.说明: Amazon S3 Glacier是一种安全、耐用且成本极低的云存储服务,用于数据归档和长期备份。 When you need to use the file you perform a restore request,you pay a retrieval pricing and after couple of hours the object is enabled and ready.当您需要使用执行恢复请求的文件时,您需要支付检索价格,几个小时后 object 将启用并准备就绪。 This feature usually use companies to archive files/logs/databases/backups when this data is rarely consumed.当这些数据很少被使用时,此功能通常使用公司来归档文件/日志/数据库/备份。

Solution : In order to get glacier files you need to initiate a restore request, monitor the status of the restore request, as soon as it finishes change the object of the storage class (standard) and copy it.解决方案:为了获取冰川文件,您需要发起恢复请求,监控恢复请求的状态,一旦完成更改存储 class(标准)的 object 并复制它。 You can use aws reference您可以使用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

You wrote that you needed "to copy all the files" to a local folder, assuming you wanted to copy the files recursively.你写道你需要“将所有文件复制”到本地文件夹,假设你想递归复制文件。

Because the files are kept in the Glacier storage class, you need to restore them from the Glacier archive first before you could copy them to your local folder, ie make the files available for retrieval for a specified number of days.由于文件保存在 Glacier 存储 class 中,您需要先从 Glacier 存档中恢复它们,然后才能将它们复制到本地文件夹,即让文件在指定的天数内可供检索。 After the restore completes, you can copy the files specifying the --force-glacier-transfer parameter until the term that you have specified in days expire.恢复完成后,您可以复制指定--force-glacier-transfer参数的文件,直到您以天为单位指定的期限到期。

Unless you store the files in the "S3 Glacier Instant Retrieval" storage class, you should first restore the files (make them available for retrieval) so that --force-glacier-transfer option would not fail.除非您将文件存储在“S3 Glacier Instant Retrieval”存储 class 中,否则您应该首先恢复文件(使它们可供检索),这样--force-glacier-transfer选项就不会失败。 Therefore, the solution proposed at https://stackoverflow.com/a/62651252/6910868 does not apply to "S3 Glacier Deep Archive" storage class, for which you have to explicitly issue the restore-object command and wait for its completion before you can copy files to your local folder.因此,在https://stackoverflow.com/a/62651252/6910868提出的解决方案不适用于“S3 Glacier Deep Archive”存储 class,为此您必须明确发出restore-object命令并等待其完成之前您可以将文件复制到本地文件夹。

However, the aws s3api restore-object restores just one file and does not support recursive restore.但是, aws s3api restore-object只恢复一个文件,不支持递归恢复。 The solution specified at https://stackoverflow.com/a/65925266/6910868 does not work for a recursive directory or when you have multiple files so that you wish to specify just the folder without listing all the files one by one.https://stackoverflow.com/a/65925266/6910868指定的解决方案不适用于递归目录,或者当您有多个文件时,您希望仅指定文件夹而不是一一列出所有文件。

As an alternative, instead of restoring the files by making them available for retrieval, you can change the object's storage class to Amazon S3 Standard.作为替代方案,您可以将对象的存储 class 更改为 Amazon S3 标准,而不是通过使文件可供检索来恢复文件。 To do that, you can copy the files within S3, either by overwriting the existing files or by copying the files from one S3 location into another S3 location.为此,您可以通过覆盖现有文件或将文件从一个 S3 位置复制到另一个 S3 位置来复制 S3 中的文件。 In each case, you should specify the correct destination storage class.在每种情况下,您都应该指定正确的目标存储 class。

If you just need to retrieve recursive files from the Glacier storage class without changing the storage class or making additional copies within S3, you can use the Perl script that lists the files recursively and then restores them from Glacier individually.如果您只需要从 Glacier 存储 class 检索递归文件而不更改存储 class 或在 S3 中制作额外的副本,您可以使用Perl 脚本递归列出文件,然后分别从 Glacier 恢复它们。 This script may be used not only to initiate the restore using the specified restore tier, but to monitor the process as well.此脚本不仅可用于使用指定的还原层启动还原,还可用于监视该过程。

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

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