AWS
AWS

AWS Glacier Getting Started

AWS Glacier Getting Started

AWS Glacier

AWS Glacier

Amazon Glacier provides a management console, which you can use to create and delete vaults. However, all other interactions with Amazon Glacier require that you use the AWS Command Line Interface (CLI) or write code.

There are multiple Approach’s to use AWS Glacier

1) AWS Glacier : Direct Glacier API/SDK

Glacier API or SDK

Glacier API or SDK

2) AWS Glacier: S3 Life Cycle Archival

Seamlessly move data from Amazon S3 to Amazon Glacier
Automated lifecycle rules
Transition based on object age or pre-defined date

Glacier Approach Lifecycle

Glacier Approach Lifecycle

 

3) AWS Glacier – Backup Software Integration with Commvault Simpana or similar solution

 

Glacier through Simpana

Glacier through Simpana

AWS Glacier Vault

Non-overwrite, non-erasable records
Time-based retention with “ArchiveAgeInDays” control
Policy lockdown (strong governance)
Legal hold with vault-level tags
Configure optional D3P and grant temporary access

Example Control: 1 year record retention

Glacier Vault Policy

Glacier Vault Policy

Vault Lock in the Glacier Console

Now let’s look at how to we COPY and AMI to Glacier

Summary
1. Create and deploy an AMI
2. Then Create a Bundle
3. Upload the Bundle to S3
4. And i have an S3 Policy to copy the Data to the Glacier Vault

Create and AMI
Install AMI tools in the AMI
Reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-up-ami-tools.html

Create a Bundle

$EC2_AMITOOL_HOME/bin/ec2-bundle-vol -k /tmp/cert/pk-PrivateKeyCertificateFile.pem -c /tmp/cert/cert-PublicKeyCertificateFile.pem -u your_aws_account_id -r x86_64 -e /tmp/cert –partition gpt

Note: -k is Private Key and –c use the Public Key certificate file
Upload the Bundle to S3

ec2-upload-bundle -b S3BucketLocation -m /tmp/image.manifest.xml -a ACCESSKEY -s SECRETKEY

Configure a Life Cycle Policy in S3

Once you have configured the lifecycle policy you would see object of Glacier type in the S3 bucket.

Glacier S3 Object

Glacier S3 Object

Note: After enabling versioning for the bucket don’t forget to use the “Show” button for the s3bucket.

Glacier S3 show

Glacier S3 show

 

In the below python example let’s look at how to

# List Vaults
# Create a Vault and Upload data to an archive
# List the number of jobs
# Keep track of the archive id
# Delete the archive in the vault
# Describe a Job
# Describe a Vault

Python Examples of using AWS S3

import boto3

s3 = boto3.resource(‘s3’)
for bucket in s3.buckets.all():
print (bucket.name)

Python Examples of using AWS Glacier

 

import boto3
import json
import pprint

awsAccess = “AccessKey”
awsSecret =  “SecretKey”
vName = “Vaultnamehere”
fileName = “filenamehereincludingthepath”
fileDesc = “AmazonEMRZipFile”

glacier = boto3.client(‘glacier’, region_name=’ap-south-1′)

#List Vaults
”’
response = glacier.list_vaults()
print json.dumps(response,indent=1)
”’

#Create a Vault and Upload data to an archive
”’
#myvault = glacier.create_vault(vaultName=vName)
#archive = glacier.upload_archive(vaultName=vName, archiveDescription=fileDesc, body=fileName)
”’
# List the number of jobs

”’
response = glacier.list_jobs(vaultName=vName)
print json.dumps(response,indent=1)
”’

# Please do keep track of the archive id

”’
archiveid = glacier.upload_archive(vaultName=vName, archiveDescription=fileDesc, body=fileName)
print json.dumps(archiveid,indent=1)
getvault = glacier.describe_vault(vaultName=vName)
print json.dumps(getvault,indent=1)
”’

# If you ever want, you can delete the archive on the vault
”’
# with the archive ID.
# v.delete_archive(archiveID)
”’

# Describe a JOB
”’
response = glacier.describe_job(vaultName=vName, jobId=”JOBIDHERE”)
print json.dumps(response,indent=1)
”’

#Describe a Vault
response = glacier.describe_vault(vaultName=vName)
pprint.pprint(response)

 

Leave a comment