Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
If you're new to archival storage in Amazon Simple Storage Service (Amazon S3), we recommend that you start by
learning more about the S3 Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. For more information, see S3 Glacier storage classes and
Storage classes for archiving objects in the Amazon S3 User
Guide.
Use DescribeJob
with an Amazon SDK or command line tool
The following code examples show how to use DescribeJob
.
- CLI
-
- Amazon CLI
-
The following command retrieves information about an inventory retrieval job on a vault named my-vault
:
aws glacier describe-job --account-id - --vault-name my-vault --job-id zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW
Output:
{
"InventoryRetrievalParameters": {
"Format": "JSON"
},
"VaultARN": "arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault",
"Completed": false,
"JobId": "zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW",
"Action": "InventoryRetrieval",
"CreationDate": "2015-07-17T20:23:41.616Z",
"StatusCode": "InProgress"
}
The job ID can be found in the output of aws glacier initiate-job
and aws glacier list-jobs
.
Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.
- PowerShell
-
- Tools for PowerShell
-
Example 1: Returns details of the specified job. When the job completes successfully the Read-GCJobOutput cmdlet can be used to retrieve the contents of the job (an archive or inventory list) to the local file system.
Get-GLCJob -VaultName myvault -JobId "op1x...JSbthM"
Output:
Action : ArchiveRetrieval
ArchiveId : o9O9j...X-TpIhQJw
ArchiveSHA256TreeHash : 79f3ea754c02f58...dc57bf4395b
ArchiveSizeInBytes : 38034480
Completed : False
CompletionDate : 1/1/0001 12:00:00 AM
CreationDate : 12/13/2018 11:00:14 AM
InventoryRetrievalParameters :
InventorySizeInBytes : 0
JobDescription :
JobId : op1x...JSbthM
JobOutputPath :
OutputLocation :
RetrievalByteRange : 0-38034479
SelectParameters :
SHA256TreeHash : 79f3ea754c02f58...dc57bf4395b
SNSTopic :
StatusCode : InProgress
StatusMessage :
Tier : Standard
VaultARN : arn:aws:glacier:us-west-2:012345678912:vaults/test
- 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_status(job):
"""
Gets the status of a job.
:param job: The job to query.
:return: The current status of the job.
"""
try:
job.load()
logger.info(
"Job %s is performing action %s and has status %s.",
job.id,
job.action,
job.status_code,
)
except ClientError:
logger.exception("Couldn't get status for job %s.", job.id)
raise
else:
return job.status_code
For a complete list of Amazon SDK developer guides and code examples, see
Using S3 Glacier with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.