0
votes

Collected the snapshot ID's in AWS account and trying to move them to s3 glacier using below script and got the response with Archive-Id. Later, i checked the glacier vault and found the number of archives updated to the right number but in terms of size it did not reflect.

snapshots that were moved to glacier was 10gb each. Wanted to know if snapshots really movied to glacier correctly or not?

Code:

session=boto3.session.Session()
ec2=session.client('ec2', region_name='ap-south-1')
response = ec2.describe_snapshots(OwnerIds=['ID'])
snapshots=[]
for snapshot in  response['Snapshots']:
    snapshots.append(snapshot['SnapshotId'])
print snapshots

client = boto3.client('glacier')
for snap in snapshots:
    response_vault = client.upload_archive(
        vaultName='myvault',
        archiveDescription='sampe description',
        body=snap
)
print response_vault

Response:

['snap-0dc11fa8b39147491', 'snap-0eb965248ccfcd148']
{u'archiveId': 'wYgB9h3AV7hQ2gtCO-mGX_v_D4RZQHoH74zJY8IMtGhwmSh589nMr8dBC9RO8qRU4dm4do-Nj-qkSffxyZrQiqBOF_2s6MT2vrYzRoHbl6x1zMin64VJUqb_MyARCHiveID', u'checksum': 'f43bd06e74619b42670df5f98f6749bdd6f40633674e3ea5d506155a87cbff95', u'location': '/AWSAccountID/vaults/myvault/archives/wYgB9h3AV7hQ2gtCO-mGX_v_D4RZQHoH74zJY8IMtGhwmSh589nMr8dBC9RO8qRU4dm4do-Nj-qkSffxyZrQiqBOF_2s6MT2vrYzRoHbl6x1zMin64VJUqbUm87_MyARchiveID', 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 201, 'RequestId': 'iutAhBmVCC8KG6_eknwTOHXrid4ddv6Mm3o7_1wER0QOSas', 'HTTPHeaders': {'x-amzn-requestid': 'iutAhBmVCC8KG6_eknwTOHXrid4ddv6Mm3o7_1wER0QOSas', 'content-length': '2', 'x-amz-archive-id': 'wYgB9h3AV7hQ2gtCO-mGX_v_D4RZQHoH74zJY8IMtGhwmSh589nMr8dBC9RO8qRU4dm4do-Nj-qkSffxyZrQiqBOF_2s6MT2vrYzRoHbl6x1zMin64VJUqbUm87H65KPv9gKkA89qw', 'x-amz-sha256-tree-hash': 'f43bd06e74619b42670df5f98f6749bdd6f40633674e3ea5d506155a87cbff95', 'date': 'Thu, 17 Oct 2019 12:12:05 GMT', 'content-type': 'application/json', 'location': '/AWSAccountID/vaults/myvault/archives/wYgB9h3AV7hQ2gtCO-mGX_v_D4RZQHoH74zJY8IMtGhwmSh589nMr8dBC9RO8qRU4dm4do-Nj-qkSffxyZrQiqBOF_2s6MT2vrYzRoHbl6x1zMin64VJUqbUm87_myArchiveID'}}}
[root@Server ~]#

My Vault output:

Vault Name: myvault
Details Notifications Permissions Vault Lock Tags
Region:     Asia Pacific (Mumbai)
Created on:     Oct 3, 2019 2:38:47 PM
Vault ARN:  arn:aws:glacier:ap-south-1:ID:vaults/sample_vault
Inventory Last Updated:     Oct 18, 2019 6:04:40 AM
Vault Details as of the last inventory update:
Size:   32.1 MB
# of Archives:  3  ##earlier it was 1.

Also, when trying to retrieve an archive in vault by initiating an archive-retrieval job it returns HTTPStatusCode: 200 and <botocore.response.StreamingBody object at 0x7fb6ae3b1e10>. How to get that archive present in memory location? I did not mention any s3 bucket in retrieval job. can i still get the archive?

RetrievalJob code:

import boto3

client=boto3.client('glacier')
response = client.initiate_job(
    accountId='-',
    jobParameters={
        'Type': 'archive-retrieval',
        'ArchiveId':'fKPh8G-ar1zIdIpxXAdLctJNO7busQ40tXMLt-WiDlNyAafcsuiDihXvpBckwudqG5WKkrzF6l3BsytMdUBuX1mHB3x1pNkj5D35ajZyHMEWYD1kOATqRtixU_myjob',
        'Description': 'My archive retrieval job',
        'SNSTopic': 'arn:aws:sns:ap-south-1:ID:ec2volumes_purge_glacier',
        'Tier': 'Standard'
    },
    vaultName='myvault',
)
1

1 Answers

0
votes

The describe_snapshots() command returns information about Amazon EBS Snapshots. It does not return the snapshots themselves.

Therefore, your Amazon Glacier archive probably contained the JSON returned by the describe_snapshots() command, rather than the snapshots themselves.

The contents of a Snapshot can only be accessed by Amazon EBS itself, when creating a new volume from a snapshot.