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