I once used Arq – a backup program for Mac – to backup all my documents to Amazon’s AWS cloud. I decided to use Glacier, a low-cost and long-term option to do this.

However, it all got out of sync and Arq wanted to re-back everything up when I reinstalled my Mac OS X, so I decided to ditch it.

That left me with many vaults on Amazon Glacier that I couldn’t get rid of – but was still paying for. The AWS Console only allows you to delete vaults if they are empty.

There’s this error message. How annoying!

Screen Shot 2014-06-25 at 11.01.08 am

There is a way to delete the archives and vaults, but it takes a few steps. Here’s how I did it.

1) Find a VPS provider and spin up a new server

I used Digital Ocean. It’s quick and cheap and easy. I used a VPS because at the end, I can nuke it and not worry about having programs I will no longer need installed on my computer.

Screen Shot 2014-06-25 at 10.34.48 am

I installed Ubuntu 12.04.4 x64

2) SSH into your new VPS

Once you’ve SSHed into the server, you’ll have to install a bit of software.

I used this “Perl Multithreaded multipart sync to Amazon Glacier service.

To install, I ran this commands:

sudo apt-get update
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:vsespb/mt-aws-glacier
sudo apt-get update
sudo apt-get install libapp-mtaws-perl

That will install the software needed to interface with Glacier.

From there, you’ll need to get your Amazon security tokens to the software can connect to the cloud.

You’ll need to put it into a config file. Here’s an example of what it should look like:

#region: eu-west-1, us-east-1 etc
#protocol=http (default) or https

I called my file: glacier.cfg

Once you’ve done that, you’ll need to get the “inventory” of each vault you want to delete.

To do that, log into the AWS Console and go to the Glacier section. Find the region the vault is stored.

You’ll see a list of the vaults:

Screen Shot 2014-06-25 at 10.51.21 am

Then run this command for each of the vaults:

mtglacier retrieve-inventory --config glacier.cfg --vault vault-name

Replace “vault-name” with the name of the vault you see in the list.

If you’ve done it correctly, you should see something like:

MT-AWS-Glacier, Copyright 2012-2014 Victor Efimov http://mt-aws.com/ Version 1.115

PID 2551 Started worker  

Do it for each of the vaults you want to delete.

Once you’ve done that, you’ll need to wait a while. Possibly a few hours. I waited about eight or so.

After you’ve waited, there are a few more commands to run:

Firstly, you’ll need to download the inventory. Replace “vault-name” twice. Once for the name of the vault and once so the vault’s name matches the log file.

mtglacier download-inventory --config glacier.cfg --vault vault-name --new-journal vault-name.log

You’ll see a similar message as above.

Then, you need to purge the vault. Here’s the command. Don’t forget to replace the “vault-name” and make sure the .log file matches what you set it to in the previous step.

mtglacier purge-vault --config glacier.cfg --vault vault-name --journal vault-name.log

It should then run through the vault and delete the archives. Depending on how many archives are in the vault, it may take a while. It took me about 10-15 minutes to delete 20,000 archives – so don’t get impatient. Just let it run.

Once that’s done, you may have to wait a while again. Then the vaults will be empty. You can then delete from the AWS Glacier Console!