This page is only for existing customers of the S3 Glacier service using Vaults and the original REST API from 2012.
If you're looking for archival storage solutions we suggest using the S3 Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. To learn more about these storage options, see S3 Glacier storage classes and
Long-term data storage using S3 Glacier storage classes in the Amazon S3 User
Guide. These storage classes use the Amazon S3 API, are available in all regions, and can be managed within the Amazon S3 console. They offer features like Storage Cost Analysis, Storage Lens, advanced optional encryption features, and more.
Use GetJobOutput
with an AWS SDK or CLI
The following code examples show how to use GetJobOutput
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- CLI
-
- AWS CLI
-
The following command saves the output from a vault inventory job to a file in the current directory named output.json
:
aws glacier get-
job-output --account-id - --vault-name my-vault
--job-id zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW
output.json
The job-id
is available in the output of aws glacier list-jobs
. Note that the output file name is a positional argument that is not prefixed by an option name. Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.
Output:
{
"status": 200,
"acceptRanges": "bytes",
"contentType": "application/json"
}
output.json
:
{"VaultARN":"arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault","InventoryDate":"2015-04-07T00:26:18Z","ArchiveList":[{"ArchiveId":"kKB7ymWJVpPSwhGP6ycSOAekp9ZYe_--zM_mw6k76ZFGEIWQX-ybtRDvc2VkPSDtfKmQrj0IRQLSGsNuDp-AJVlu2ccmDSyDUmZwKbwbpAdGATGDiB3hHO0bjbGehXTcApVud_wyDw","ArchiveDescription":"multipart upload test","CreationDate":"2015-04-06T22:24:34Z","Size":3145728,"SHA256TreeHash":"9628195fcdbcbbe76cdde932d4646fa7de5f219fb39823836d81f0cc0e18aa67"}]}
- PowerShell
-
- Tools for PowerShell
-
Example 1: Downloads the archive content that was scheduled for retrieval in the specified job and stores the contents into a file on disk. The download validates the checksum for you, if one is available.
If desired the entire response including the checksum can be returned by specifying -Select '*'
.
Read-GLCJobOutput -VaultName myvault -JobId "HSWjArc...Zq2XLiW" -FilePath "c:\temp\blue.bin"
- Python
-
- SDK for Python (Boto3)
-
class GlacierWrapper:
"""Encapsulates Amazon S3 Glacier API operations."""
def __init__(self, glacier_resource):
"""
:param glacier_resource: A Boto3 Amazon S3 Glacier resource.
"""
self.glacier_resource = glacier_resource
@staticmethod
def get_job_output(job):
"""
Gets the output of a job, such as a vault inventory or the contents of an
archive.
:param job: The job to get output from.
:return: The job output, in bytes.
"""
try:
response = job.get_output()
out_bytes = response["body"].read()
logger.info("Read %s bytes from job %s.", len(out_bytes), job.id)
if "archiveDescription" in response:
logger.info(
"These bytes are described as '%s'", response["archiveDescription"]
)
except ClientError:
logger.exception("Couldn't get output for job %s.", job.id)
raise
else:
return out_bytes
For a complete list of AWS SDK developer guides and code examples, see
Using S3 Glacier with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.