Glacier is a low cost cloud storage provided by Amazon Web Services. There are certain time limitation when retrieving your data so be sure that this is a right service for you before you decide to use Amazon Glacier service. Generally Amazon Glacier service is great for all digital archiving and backup needs, where the archived files do not need to be retrieved instantly. In this short how-to I will show how to install Amazon Glacier command interface on Linux, configuration and basic usage. Before you continue make sure that you have already signed up for AWS and you posses a valid AWS access and secret key.

Installation of Amazon Glacier command interface

Let's begin with Amazon Glacier command interface installation on Linux system. First, we need to install all prerequisites:

Redhat/CentOS/Fedora

# yum install git wget
Next, we need to install setuptools:
# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz --no-check-certificate
# tar xzf setuptools-7.0.tar.gz
# cd setuptools-7.0
# python setup.py install

Ubuntu/Debian

# apt-get install git python-setuptools python
At this point we are done with all prerequisites installations so let's proceed with the actual amazon-glacier-cmd-interface installation:
# git clone git://github.com/uskudnik/amazon-glacier-cmd-interface.git
# cd amazon-glacier-cmd-interface/; python setup.py install
Done. Now you should have glacier command available on you Linux system.

Configuration of Amazon Glacier command interface

Depending on your needs the configuration of Amazon Glacier command interface can be simple as creating a ~/.glacier-cmd config file with a following content replacing your AWS access and secret key:
NOTE: Below AWS access and secret keys are invalid and are provided for illustration purposes only!
$ vi ~/.glacier-cmd
[aws]
aws-access-key=AGIBJ7HKLQEIH5VQ8IFA
aws-secret-key=Bn7Y3EEi1/dFB/kh2+5L+YD4HheZHagaa05Vy+Op

[glacier]
region=ap-southeast-2
logfile=~/.glacier-cmd.log
loglevel=INFO
output=print

Basic usage of glacier command interface

First, create your glacier vault:
$ glacier-cmd mkvault web-backup
+-----------+-------------------------------------------------+
|   Header  |                      Value                      |
+-----------+-------------------------------------------------+
| RequestId | e4jCaHOsuy5c5Lfno0K7YtOoaQbzUOVHmYQcU29Z1dmAuUk |
|  Location |         /718281424278/vaults/web-backup         |
+-----------+-------------------------------------------------+
List all avaiable vaults:
$ glacier-cmd lsvault
+------+---------------------------------------------------------------+--------------------------+------------+
| Size |                              ARN                              |         Created          | Vault name |
+------+---------------------------------------------------------------+--------------------------+------------+
|  0   | arn:aws:glacier:ap-southeast-2:718281424278:vaults/web-backup | 2015-01-01T10:40:22.054Z | web-backup |
+------+---------------------------------------------------------------+--------------------------+------------+
Upload file mysite_backup.tar.gzto web-backup vault:
$ ls -hl mysite_backup.tar.gz
-rw-r--r--. 1 root root 4.8M Jan  2 20:46 mysite_backup.tar.gz
$ glacier-cmd upload web-backup mysite_backup.tar.gz --description "My first web backup file"
Wrote 4.8 MB. Rate 78.40 KB/s. Rate 105.57 KB/s, average 79.61 KB/s, ETA 20:50:28.                                                                              
+--------------------------+------------------------------------------------------------------+                                          
|          Header          |                              Value                               |
+--------------------------+------------------------------------------------------------------+
| Archive SHA256 tree hash | ec494506b61602f888ad3607818f3146edeae1a49414d176be0958578c9c6397 |
|      Uploaded file       |                       mysite_backup.tar.gz                       |
+--------------------------+------------------------------------------------------------------+

Additional glacier-cmd command usage

Please note that it may take up to 24 hours for your inventory to by updated by Amazon Glacier service. This means that the commands such as an inventory list retrieval may be outdated and thus my not contain recent uploads.

List Glacier Inventory

List all archives within web-backup inventory:
$ glacier-cmd inventory web-backup

Download Glacier archive

The download a glacier archive consists of two parts. Example, first, we initiate download request of archive from web-backup inventory with ID audyrn0wi:
$ glacier-cmd getarchive web-backup audyrn0wi
It will take several hours for Amazon Glacier service to complete the above request. Once the above request is completed you can download the above archive with:
$ glacier-cmd download web-backup audyrn0wi

Remove Glacier Archive

Remove archive from web-backup inventory with archive ID audyrn0wi:
glacier-cmd rmarchive web-backup audyrn0wi

Glacier Vault Details

To obtain additional information about your glacier vault details run:
$ glacier-cmd describevault web-backup
The above glacier-cmd command will display extra information about web-backup vault.

Remove Glacier Vault

Please note that you are only able to remove an empty vault. In case you need to remove glacier vault you first need to remove all archives from your vault. For example to remove glacier vault named web-backup run:
$ glacier-cmd rmvault web-backup

List Active Glacier Jobs

Below command will display all active jobs of web-backup glacier inventory:
$ glacier-cmd listjobs web-backup

Conclusion

In case that you like to keep your files encrypted before uploading them to AWS Glacier you can encrypt files with tool like OpenSSL. The above should get you started with Amazon Glacier AWS service on Linux. To get more information about the usage of glacier-cmd command run:
$ glacier-cmd --help
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: