DEV Community

Cover image for How To Save Files To AWS Glacier
Anthony
Anthony

Posted on

How To Save Files To AWS Glacier

Uploading files to Amazon's AWS S3 cloud storage server is very simple because to a handy web interface and a number of different ways to add a third-party graphical UI tool... if you are into that sort of thing. Glacier is a bit different as it's not designed to be the sort of storage that you interact with as regularly so, understandably, getting files into and out of the service isn't as easy as general S3.

Step One: CLI

In order to work with AWS Glacier you'll need Amazon's CLI service, which is its command line interface. This tool is a bit difficult to approach if you aren't used to working with the command line, but once you learn the basics it's quite straightforward, plus it's very powerful. With great power comes great responsibility (as to the safety of your files) so use it with care, especially if you don't have extensive permissions (IAM) setup in your org.

Step Two: S3

Hop into S3 and create any buckets you might need. Glacier is, after all, a subset of S3, so you can use the S3 web interface to interact with Glacier-class files as well as set lifecycle management. This will enable you to move files from S3 into your "cold" storage (the name making more sense now?).

You can, of course, create buckets and vaults, etc. using the CLI if you are feeling saucy.

Step Three:

Open up your terminal or command line and confirm AWS CLI is installed. A simple version check will do the jog:

$ aws --version

All good? Now decide, do you want to upload a single file or multiple files.

Single File Upload To Glacier

aws s3 cp /Users/USERNAME/folder/folder2/fileName s3://myBucketName --storage-class GLACIER

Here you are coping the file from your local machine to an S3 bucket, with the storage class of "Glacier." Pretty straightforward right?

Multiple File Upload To Glacier

aws s3 cp /Users/USERNAME/folder/folder2/ s3://myBucketName --storage-class GLACIER --recursive

If you have a folder and you'd like to upload all the files in it to Glacier, you simply need to specify the folder and then add the recursive command. You can watch the upload progress in your terminal.

Perhaps you have a bunch of videos you'd like to save, some family images, or massive amounts of airport wait time data, or any other random thing you might have picked up in your software development adventures.

Remember, AWS CLI has a huge number of tools and capabilities so it's much more than just a convenient way to upload files without logging into AWS. It can stream multiple files from your computer to S3 at once, it can be used to split huge files (which would fail if being uploads via the web interface) as well as do many other cool things like multi-part uploads].

Top comments (0)