本文介绍了AWS S3 Glacier-以编程方式启动还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在编写一个使用s3进行存储并使用冰川进行备份的Web应用程序。因此,我设置了生命周期策略来对其进行存档。现在,我想编写一个列出存档文件的Web应用程序,用户应该能够从中启动还原,然后在还原完成后收到一封电子邮件。

I have been writing an web-app using s3 for storage and glacier for backup. So I setup the lifecycle policy to archive it. Now I want to write a webapp that lists the archived files, the user should be able to initiate restore from this and then get an email once their restore is complete.

现在我遇到的麻烦是我找不到可以发出的initialRestore的php sdk命令。然后,如果还原完成时通知SNS,SNS将JSON推送到SQS上,我将对SQS进行轮询,并在轮询检测到完整的还原时最终向用户发送电子邮件。

Now the trouble I am running into is I cant find a php sdk command I can issue to initiateRestore. Then it would be nice if it notified SNS when restore was complete, SNS would push the JSON onto SQS and I would poll SQS and finally email the user when polling detected a complete restore.

任何帮助或建议都会很好。
谢谢。

Any help or suggestions would be nice.Thanks.

推荐答案

您也可以使用就像(这里我假设您要还原一个目录中的所有文件)

aws s3 ls s3://myBucket/myDir/ | awk '{if ($4) print $4}' > myFiles.txt
for x in `cat myFiles.txt`
do
    echo "restoring $x"
    aws s3api restore-object \
        --bucket myBucket \
        --key "myDir/$x" \
        --restore-request '{"Days":30}'
done

关于通知的期望,如果请求已启动,CLI工具将报告发生客户端错误(RestoreAlreadyInProgress):对象还原已在进行中 ,恢复后可能会显示其他消息。您可以多次运行此还原命令,以查找还原完成错误/消息。当然很

Regarding your desire for notification, the CLI tool will report "A client error (RestoreAlreadyInProgress) occurred: Object restore is already in progress" if request already initiated, and probably a different message once it restores. You could run this restore command several times, looking for "restore done" error/message. Pretty hacky of course; there's probably a better way with AWS CLI tool.

注意::请小心Glacier还原,该还原超出了分配的免费还原量/期限。如果您太快地恢复了太多数据,则收费会成倍增加。

Caveat: be careful with Glacier restores that exceed the allotted free-restore amount/period. If you restore too much data too quickly, charges can exponentially pile up.

这篇关于AWS S3 Glacier-以编程方式启动还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 21:54