How to restore folders (or entire buckets) to Amazon S3 from Glacier?

后端 未结 10 815
天命终不由人
天命终不由人 2020-12-23 12:47

I changed the lifecycle for a bunch of my buckets on Amazon S3 so their storage class was set to Glacier. I did this using the online AWS Console. I now need those files a

10条回答
  •  無奈伤痛
    2020-12-23 13:17

    A variation on Dustin's answer to use AWS CLI, but to use recursion and pipe to sh to skip errors (like if some objects have already requested restore...)

    BUCKET=my-bucket
    BPATH=/path/in/bucket
    DAYS=1
    aws s3 ls s3://$BUCKET$BPATH --recursive | awk '{print $4}' | xargs -L 1 \
     echo aws s3api restore-object --restore-request Days=$DAYS \
     --bucket $BUCKET --key | sh
    

    The xargs echo bit generates a list of "aws s3api restore-object" commands and by piping that to sh, you can continue on error.

    NOTE: Ubuntu 14.04 aws-cli package is old. In order to use --recursive you'll need to install via github.

    POSTSCRIPT: Glacier restores can get unexpectedly pricey really quickly. Depending on your use case, you may find the Infrequent Access tier to be more appropriate. AWS have a nice explanation of the different tiers.

提交回复
热议问题