从AWS Glacier恢复至S3的文件:临时存储位置及剩余时长查询
Great question! When you restore an object from AWS Glacier to S3, that "temporary copy" isn't a separate object in some hidden location—it's actually the original Glacier object, temporarily accessible in S3's standard storage tier for your specified duration. The confusion comes because the object's StorageClass still shows as GLACIER, but it has metadata flags indicating it's restored. Here's how to check the details:
Check Details for a Single Restored Object
Use the head-object command to pull the object's metadata, which includes restore status and expiry time:
aws s3api head-object --bucket YOUR_BUCKET_NAME --key YOUR_OBJECT_KEY
Look for the Restore field in the response—it will look something like this:
"Restore": "ongoing-request=\"false\", expiry-date=\"Fri, 15 Nov 2024 00:00:00 GMT\""
ongoing-request="false"means the restore is complete and the object is accessibleexpiry-datetells you when the temporary access will end (you can calculate the remaining duration by comparing this to the current time)
List All Restored Objects in a Bucket
To batch-find all objects that are currently restored (and see their expiry times), use list-objects-v2 with a query filter to target objects with non-null Restore metadata:
aws s3api list-objects-v2 --bucket YOUR_BUCKET_NAME --query "Contents[?Restore != null]"
This will return only objects that have an active temporary restore, and each entry will include the Restore field with expiry details.
Why Standard List Commands Don't Show This
The list-objects and list-objects-v2 commands without filters show all objects, but they don't highlight the Restore metadata by default. Since the object's storage class remains GLACIER, you need to explicitly filter or check the metadata to see which ones are temporarily accessible.
This method works regardless of which tool you used to initiate the restore—all restore operations update the object's metadata in S3, so the AWS CLI commands will pick up the status correctly.
内容的提问来源于stack exchange,提问作者Oli

