I archived an Amazon Simple Storage Service (Amazon S3) object to the Amazon Glacier storage class by using a lifecycle configuration. How can I restore the object using the AWS Command Line Interface (AWS CLI)? 

Follow these steps to restore an S3 object from the Amazon Glacier storage class using the AWS CLI:

Initiate a restore request

Run the following command to initiate a restore request. Be sure to replace all values in the example command with the values for your bucket, object, and restore request. 

$ aws s3api restore-object --bucket mybucket --key dir1/example.obj --restore-request '{"Days":25,"GlacierJobParameters":{"Tier":"Standard"}}'

After you run this command, a temporary copy of the object is made available for the duration specified in the restore request, such as 25 days in this example.

Note the following modifications that you can make to the command:

  • To restore a specific object version in a versioned bucket, include the --version-id option and specify the corresponding version ID.
  • If the JSON syntax used in the example results in an error on a Windows client, replace the restore request with the following syntax:
--restore-request Days=25,GlacierJobParameters={"Tier"="Standard"}

Monitor the status of your restore request

Run the following command to monitor the status of your restore request:  

aws s3api head-object --bucket mybucket --key dir1/example.obj

After you run the command, you'll receive a response similar to the following if the restore is still in progress: 

{
    "Restore": "ongoing-request=\"true\"",
    ...
    "StorageClass": "GLACIER",
    "Metadata": {}
}

After the restore is complete, the response is similar to the following: 

{
    "Restore": "ongoing-request=\"false\", expiry-date=\"Sun, 13 Aug 2017 00:00:00 GMT\"",
    ...
    "StorageClass": "GLACIER",
    "Metadata": {}
}

Note the expiry-date in the response—you must transition the object back to the Amazon S3 Standard storage class by that date.

Transition the object back to the Amazon S3 Standard storage class

To transition the object back to the Amazon S3 Standard storage class, run a copy operation by either overwriting the existing object or copying the object into another location.

To overwrite the existing object with the Amazon S3 Standard storage class, run this command: 

aws s3 cp s3://mybucket/dir1/example.obj s3://mybucket/dir1/example.obj --storage-class STANDARD

To copy the object into another location, run this command: 

aws s3 cp s3://mybucket/dir1/example.obj s3://mybucket/dir2/example2.obj

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-07-12