POST Object restore
Description
This operation performs the following types of requests:
-
select
– Perform a select query on an archived object -
restore an archive
– Restore an archived object
To use this operation, you must have permissions to perform the
s3:RestoreObject
and s3:GetObject
actions. The bucket
owner has this permission by default and can grant this permission to others. For more
information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3
Resources in the Amazon Simple Storage Service User Guide.
Querying Archives with Select Requests
You use a select type of request to perform SQL queries on archived objects. The archived objects that are being queried by the select request must be formatted as uncompressed comma-separated values (CSV) files. You can run queries and custom analytics on your archived data without having to restore your data to a hotter Amazon S3 tier. For an overview about select requests, see Querying Archived Objects in the Amazon Simple Storage Service User Guide.
When making a select request, do the following:
-
Define an output location for the select query's output. This must be an Amazon S3 bucket in the same AWS Region as the bucket that contains the archive object that is being queried. The AWS account that initiates the job must have permissions to write to the S3 bucket. You can specify the storage class and encryption for the output objects stored in the bucket. For more information about output, see Querying Archived Objects in the Amazon Simple Storage Service User Guide.
For more information about the
S3
structure in the request body, see the following:-
Managing Access with ACLs in the Amazon Simple Storage Service User Guide
-
Protecting Data Using Server-Side Encryption in the Amazon Simple Storage Service User Guide
-
Define the SQL expression for the
SELECT
type of restoration for your query in the request body'sSelectParameters
structure. You can use expressions like the following examples.-
The following expression returns all records from the specified object.
SELECT * FROM Object
-
Assuming that you are not using any headers for data stored in the object, you can specify columns with positional headers.
SELECT s._1, s._2 FROM Object s WHERE s._3 > 100
-
If you have headers and you set the
fileHeaderInfo
in theCSV
structure in the request body toUSE
, you can specify headers in the query. (If you set thefileHeaderInfo
field toIGNORE
, the first row is skipped for the query.) You cannot mix ordinal positions with header column names.SELECT s.Id, s.FirstName, s.SSN FROM S3Object s
-
For more information about using SQL with S3 Glacier Select restore, see SQL Reference for Amazon S3 Select and S3 Glacier Select in the Amazon Simple Storage Service User Guide.
When making a select request, you can also do the following:
-
To expedite your queries, specify the
Expedited
tier. For more information about tiers, see "Restoring Archives," later in this topic. -
Specify details about the data serialization format of both the input object that is being queried and the serialization of the CSV-encoded query results.
The following are additional important facts about the select feature:
-
The output results are new Amazon S3 objects. Unlike archive retrievals, they are stored until explicitly deleted—manually or through a lifecycle policy.
-
You can issue more than one select request on the same Amazon S3 object. Amazon S3 doesn't deduplicate requests, so avoid issuing duplicate requests.
-
Amazon S3 accepts a select request even if the object has already been restored. A select request doesn’t return error response
409
.
Restoring Archives
Objects in the GLACIER and DEEP_ARCHIVE storage classes are archived. To access an archived object, you must first initiate a restore request. This restores a temporary copy of the archived object. In a restore request, you specify the number of days that you want the restored copy to exist. After the specified period, Amazon S3 deletes the temporary copy but the object remains archived in the GLACIER or DEEP_ARCHIVE storage class that object was restored from.
To restore a specific object version, you can provide a version ID. If you don't provide a version ID, Amazon S3 restores the current version.
The time it takes restore jobs to finish depends on which storage class the object is being restored from and which data access tier you specify.
When restoring an archived object (or using a select request), you can specify one of
the following data
access tier options in the Tier
element of the request
body:
-
Expedited
- Expedited retrievals allow you to quickly access your data stored in the GLACIER storage class when occasional urgent requests for a subset of archives are required. For all but the largest archived objects (250 MB+), data accessed using Expedited retrievals are typically made available within 1–5 minutes. Provisioned capacity ensures that retrieval capacity for Expedited retrievals is available when you need it. Expedited retrievals and provisioned capacity are not available for the DEEP_ARCHIVE storage class. -
Standard
- Standard retrievals allow you to access any of your archived objects within several hours. This is the default option for the GLACIER and DEEP_ARCHIVE retrieval requests that do not specify the retrieval option. Standard retrievals typically complete within 3-5 hours from the GLACIER storage class and typically complete within 12 hours from the DEEP_ARCHIVE storage class. -
Bulk
- Bulk retrievals are Amazon S3 Glacier’s lowest-cost retrieval option, enabling you to retrieve large amounts, even petabytes, of data inexpensively in a day. Bulk retrievals typically complete within 5-12 hours from the GLACIER storage class and typically complete within 48 hours from the DEEP_ARCHIVE storage class.
For more information about archive retrieval options and provisioned capacity for
Expedited
data access, see Restoring Archived Objects in the
Amazon Simple Storage Service User Guide.
You can use Amazon S3 restore speed upgrade to change the restore speed to a faster speed
while it is in progress. You upgrade the speed of an in-progress restoration by issuing
another restore request to the same object, setting a new Tier
request
element. When issuing a request to upgrade the restore tier, you must choose a tier that
is faster than the tier that the in-progress restore is using. You must not change any
other parameters, such as the Days
request element. For more information,
see
Upgrading the Speed of an In-Progress Restore in the
Amazon Simple Storage Service User Guide.
To get the status of object restoration, you can send a HEAD
request.
Operations return the x-amz-restore
header, which provides information
about the restoration status, in the response. You can use Amazon S3 event notifications to
notify you when a restore is initiated or completed. For more information, see Configuring Amazon S3 Event
Notifications in the Amazon Simple Storage Service User Guide.
After restoring an archived object, you can update the restoration period by reissuing the request with a new period. Amazon S3 updates the restoration period relative to the current time and charges only for the request—there are no data transfer charges. You cannot update the restoration period when Amazon S3 is actively processing your current restore request for the object.
If your bucket has a lifecycle configuration with a rule that includes an expiration action, the object expiration overrides the life span that you specify in a restore request. For example, if you restore an object copy for 10 days, but the object is scheduled to expire in 3 days, Amazon S3 deletes the object in 3 days. For more information about lifecycle configuration, see PutBucketLifecycleConfiguration and Object Lifecycle Management in Amazon Simple Storage Service User Guide.
Requests
Syntax
POST /
ObjectName
?restore&versionId=VersionID
HTTP/1.1 Host:BucketName
.s3.amazonaws.com Date:date
Authorization:authorization string
(see Authenticating Requests (AWS Signature Version 4)) Content-MD5:MD5
request body
Note
The syntax shows some of the request headers. For a complete list, see "Request Headers," later in this topic.
Request Parameters
This implementation of the operation does not use request parameters.
Request Headers
Name | Description | Required |
---|---|---|
Content-MD5 |
The base64-encoded 128-bit MD5 digest of the data. You must use this header as a
message integrity check to verify that the request body was not
corrupted in transit. For more information, see RFC
1864 Type: String Default: None |
Yes |
Request Elements
The following is an XML example of a request body for restoring an archive.
<RestoreRequest> <Days>2</Days> <GlacierJobParameters> <Tier>Bulk</Tier> </GlacierJobParameters> </RestoreRequest>
The following table explains the XML for archive restoration in the request body.
Name | Description | Required |
---|---|---|
RestoreRequest |
Container for restore information. Type: Container |
Yes |
Days |
Lifetime of the restored (active) copy. The minimum number of days that you can restore an object from S3 Glacier is 1. After the object copy reaches the specified lifetime, Amazon S3 removes it from the bucket. If you are restoring an archive, this element is required. Do not use this element with a Type: Positive integer Ancestors: |
Yes, if restoring an archive |
GlacierJobParameters |
Container for Glacier job parameters. Do not use this element with a Type: Container Ancestors: |
No |
Tier |
The data access tier to use when restoring the archive. Type: Enum Valid values: Ancestors: |
No |
The following XML is the request body for a select query on an archived object:
<RestoreRequest> <Type>SELECT</Type> <Tier>Expedited</Tier> <Description>Job description</Description> <SelectParameters> <Expression>Select * from Object</Expression> <ExpressionType>SQL</ExpressionType> <InputSerialization> <CSV> <FileHeaderInfo>IGNORE</FileHeaderInfo> <RecordDelimiter>\n</RecordDelimiter> <FieldDelimiter>,</FieldDelimiter> <QuoteCharacter>"</QuoteCharacter> <QuoteEscapeCharacter>"</QuoteEscapeCharacter> <Comments>#</Comments> </CSV> </InputSerialization> <OutputSerialization> <CSV> <QuoteFields>ASNEEDED</QuoteFields> <RecordDelimiter>\n</RecordDelimiter> <FieldDelimiter>,</FieldDelimiter> <QuoteCharacter>"</QuoteCharacter> <QuoteEscapeCharacter>"</QuoteEscapeCharacter> </CSV> </OutputSerialization> </SelectParameters> <OutputLocation> <S3> <BucketName>Name of bucket</BucketName> <Prefix>Key prefix</Prefix> <CannedACL>Canned ACL string</CannedACL> <AccessControlList> <Grantee> <Type>Grantee Type</Type> <ID>Grantee identifier</ID> <URI>Grantee URI</URI> <Permission>Granted permission</Permission> <DisplayNmae>Display Name</DisplayName> <EmailAddress>email</EmailAddress> </Grantee> </AccessControlList> <Encryption> <EncryptionType>Encryption type</EncryptionType> <KMSKeyId>KMS Key ID</KMSKeyId> <KMSContext>Base64-encoded JSON<KMSContext> </Encryption> <UserMetadata> <MetadataEntry> <Name>Key</Name> <Value>Value</Value> </MetadataEntry> </UserMetadata> <Tagging> <TagSet> <Tag> <Key>Tag name</Key> <Value>Tag value</Value> </Tag> </TagSet> </Tagging> <StorageClass>Storage class</StorageClass> </S3> </OutputLocation> </RestoreRequest>
The following tables explain the XML for a SELECT
type of restoration in the
request body.
Name | Description | Required |
---|---|---|
RestoreRequest |
Container for restore information. Type: Container |
Yes |
Tier |
The data access tier to use when restoring the archive. Type: Enum Valid values: Ancestors: |
No |
Description |
The optional description for the request. Type: String Ancestors: |
No |
SelectParameters |
Describes the parameters for the select job request. Type: Container Ancestors: |
Yes, if request type is SELECT
|
OutputLocation |
Describes the location that receives the results of the select restore request. Type: Container for Amazon S3 Ancestors: |
Yes, if request type is SELECT
|
Name | Description | Required |
---|---|---|
Expression |
The SQL expression. For example:
Type: String Ancestors: |
Yes |
ExpressionType |
Identifies the expression type. Type: String Valid values: Ancestors: |
Yes |
InputSerialization |
Describes the serialization format of the object. Type: Container for CSV Ancestors: |
Yes |
OutputSerialization |
Describes how the results of the select job are serialized. Type: Container for CSV Ancestors: |
Yes |
Name | Description | Required |
---|---|---|
RecordDelimiter |
A single character used to separate individual records in the input. Instead of the default value, you can specify an arbitrary delimiter. Type: String Default: Ancestors: |
No |
FieldDelimiter |
A single character used to separate individual fields in a record. You can specify an arbitrary delimiter. Type: String Default: Ancestors: |
No |
QuoteCharacter |
A single character used for escaping when the field delimiter is part of the value. Consider this example in a CSV file:
Wrapping the value in quotation marks makes this value a single field. If you don't use the quotation marks, the comma is a field delimiter (which makes it two separate field values, a and b). Type: String Default: Ancestors: |
No |
QuoteEscapeCharacter |
A single character used for escaping the quotation mark character inside an already
escaped value. For example, the value Type: String Default: Ancestors: |
No |
FileHeaderInfo |
Describes the first line in the input data. It is one of the ENUM values.
Type: Enum Valid values: Ancestors: |
No |
Comments |
A single character used to indicate that a row should be ignored when the character is present at the start of that row. You can specify any character to indicate a comment line. Type: String Ancestors: |
No |
Name | Description | Required |
---|---|---|
QuoteFields |
Indicates whether to use quotation marks around output fields.
Type: Enum Valid values: Default: Ancestors: |
No |
RecordDelimiter |
A single character used to separate individual records in the output. Instead of the default value, you can specify an arbitrary delimiter. Type: String Default: Ancestors: |
No |
FieldDelimiter |
A single character used to separate individual fields in a record. You can specify an arbitrary delimiter. Type: String Default: Ancestors: |
No |
QuoteCharacter |
A single character used for escaping when the field delimiter is part of the value.
For example, if the value is Type: String Default: Ancestors: |
No |
QuoteEscapeCharacter |
A single character used for escaping the quotation mark character inside an already
escaped value. For example, if the value is Type: String Ancestors: |
No |
Name | Description | Required |
---|---|---|
AccessControlList |
A list of grants that control access to the staged results. Type: Container for Grant Ancestors: |
No |
BucketName |
The name of the S3 bucket where the select restore results are stored. The bucket must be in the same AWS Region as the bucket that contains the input archive object. Type: String Ancestors: |
Yes |
CannedACL |
The canned access control list (ACL) to apply to the select restore results. Type: String Valid values: Ancestors: |
No |
Encryption |
Contains encryption information for the stored results. Type: Container for Encryption Ancestors: |
No |
Prefix |
The prefix that is prepended to the select restore results. The maximum length for the prefix is 512 bytes. Type: String Ancestors: |
Yes |
StorageClass |
The class of storage used to store the select request results. Type: String Valid values: Ancestors: |
No |
Tagging |
Container for tag information. Type: Tag structure Ancestors: |
No |
UserMetadata |
Contains a list of metadata to store with the select restore results. Type: MetadataEntry structure Ancestors: |
No |
Name | Description | Required |
---|---|---|
DisplayName |
The screen name of the grantee. Type: String Ancestors: |
No |
EmailAddress |
The email address of the grantee. Type: String Ancestors: |
No |
ID |
The canonical user ID of the grantee. Type: String Ancestors: |
No |
Type |
The type of the grantee. Type: String Ancestors: |
No |
URI |
The URI of the grantee group. Type: String Ancestors: |
No |
Permission |
Granted permission. Type: String Ancestors: |
No |
Name | Description | Required |
---|---|---|
EncryptionType |
The server-side encryption algorithm used when storing job results. The default is no encryption. Type: String Valid Values Ancestors: |
No |
KMSContext |
Optional. If the encryption type is Type: String Ancestors: Encryption |
No |
KMSKeyId |
The AWS Key Management Service (AWS KMS) key ID to use for object encryption. Type: String Ancestors: |
No |
Name | Description | Required |
---|---|---|
Tag |
Contains tags. Type: Container Ancestors: |
No |
Name | Description | Required |
---|---|---|
Key |
Name of the tag. Type: String Ancestors: |
No |
Value |
Value of the tag. Type: String Ancestors: |
No |
Name | Description | Required |
---|---|---|
MetadataKey |
The metadata key. Type: String Ancestors: |
No |
MetadataEntry |
The metadata value. Type: String Ancestors: |
No |
Responses
A successful operation returns either the 200 OK
or 202 Accepted
status code.
-
If the object copy is not previously restored, then Amazon S3 returns
202 Accepted
in the response. -
If the object copy is previously restored, Amazon S3 returns
200 OK
in the response.
Response Headers
This implementation of the operation uses only response headers that are common to most responses. For more information, see Common Response Headers.
Response Elements
This operation does not return response elements.
Special Errors
Error Code | Description | HTTP Status Code | SOAP Fault Code Prefix |
---|---|---|---|
RestoreAlreadyInProgress |
Object restore is already in progress. (This error does not apply to SELECT type requests.) | 409 Conflict | Client |
GlacierExpeditedRetrievalNotAvailable |
Glacier expedited retrievals are currently not available. Try again later.
(Returned if there is insufficient capacity to process the
Expedited request. This error applies only to
Expedited retrievals and not to
Standard or Bulk retrievals.) |
503 | N/A |
Examples
Restore an Object for Two Days Using the Expedited Retrieval Option
The following restore request restores a copy of the photo1.jpg
object from
S3 Glacier for a period of two days using the expedited retrieval option.
POST /photo1.jpg?restore HTTP/1.1 Host: examplebucket.s3.amazonaws.com Date: Mon, 22 Oct 2012 01:49:52 GMT Authorization:
authorization string
Content-Length:content length
<RestoreRequest> <Days>2</Days> <GlacierJobParameters> <Tier>Expedited</Tier> </GlacierJobParameters> </RestoreRequest>
If the examplebucket
does not have a restored copy of the object, Amazon S3
returns the following 202 Accepted
response.
HTTP/1.1 202 Accepted x-amz-id-2: GFihv3y6+kE7KG11GEkQhU7/2/cHR3Yb2fCb2S04nxI423Dqwg2XiQ0B/UZlzYQvPiBlZNRcovw= x-amz-request-id: 9F341CD3C4BA79E0 Date: Sat, 20 Oct 2012 23:54:05 GMT Content-Length: 0 Server: AmazonS3
If a copy of the object is already restored, Amazon S3 returns a 200 OK
response,
and updates only the restored copy's expiry time.
Query an Archive with a SELECT Request
The following is an example select restore request.
POST /object-one.csv?restore HTTP/1.1 Host: examplebucket.s3.amazonaws.com Date: Date: Sat, 20 Oct 2012 23:54:05 GMT Authorization:
authorization string
Content-Length:content length
<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Type>SELECT</Type> <Tier>Expedited</Tier> <Description>this is a description</Description> <SelectParameters> <InputSerialization> <CSV> <FileHeaderInfo>IGNORE</FileHeaderInfo> <Comments>#</Comments> <QuoteEscapeCharacter>"</QuoteEscapeCharacter> <RecordDelimiter>\n</RecordDelimiter> <FieldDelimiter>,</FieldDelimiter> <QuoteCharacter>"</QuoteCharacter> </CSV> </InputSerialization> <ExpressionType>SQL</ExpressionType> <Expression>select * from object</Expression> <OutputSerialization> <CSV> <QuoteFields>ALWAYS</QuoteFields> <QuoteEscapeCharacter>"</QuoteEscapeCharacter> <RecordDelimiter>\n</RecordDelimiter> <FieldDelimiter>\t</FieldDelimiter> <QuoteCharacter>\'</QuoteCharacter> </CSV> </OutputSerialization> </SelectParameters> <OutputLocation> <S3> <BucketName>example-output-bucket</BucketName> <Prefix>test-s3</Prefix> <AccessControlList> <Grant> <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail"> <EmailAddress>jane-doe@example.com</EmailAddress> </Grantee> <Permission>FULL_CONTROL</Permission> </Grant> </AccessControlList> <UserMetadata> <MetadataEntry> <Name>test</Name> <Value>test-value</Value> </MetadataEntry> <MetadataEntry> <Name>other</Name> <Value>something else</Value> </MetadataEntry> </UserMetadata> <StorageClass>STANDARD</StorageClass> </S3> </OutputLocation> </RestoreRequest>
Amazon S3 returns the following 202 Accepted
response.
HTTP/1.1 202 Accepted x-amz-id-2: GFihv3y6+kE7KG11GEkQhU7/2/cHR3Yb2fCb2S04nxI423Dqwg2XiQ0B/UZlzYQvPiBlZNRcovw= x-amz-request-id: 9F341CD3C4BA79E0 x-amz-restore-output-path: js-test-s3/qE8nk5M0XIj-LuZE2HXNw6empQm3znLkHlMWInRYPS-Orl2W0uj6LyYm-neTvm1-btz3wbBxfMhPykd3jkl-lvZE7w42/ Date: Sat, 20 Oct 2012 23:54:05 GMT Content-Length: 0 Server: AmazonS3
More Info
-
SQL Reference for Amazon S3 Select and S3 Glacier Select in the Amazon Simple Storage Service User Guide