Skip to content

Instantly share code, notes, and snippets.

@shannonwells
Last active November 11, 2015 23:40
Show Gist options
  • Save shannonwells/a0c1f59d208d84b9d271 to your computer and use it in GitHub Desktop.
Save shannonwells/a0c1f59d208d84b9d271 to your computer and use it in GitHub Desktop.
A short script illustrating how to upload items to AWS Glacier. Also includes how to split them up before uploading. Intended for occasional use.
#!/bin/bash
# This script assumes you have already installed the AWS CLI tools and the treehash Ruby gem.
VAULT=MyVaultName # AWS Glacier vault name
ACCOUNT=123456890 # AWS Account number
DIR=$HOME/mydir
TREEHASH=/Users/fair/.rvm/gems/ruby-2.2.1/bin/treehash
# on OS X, to split up files into pieces Glacier prefers/can handle
# for file in *.tar ; do split -a 3 -b 100m $file $file- ; done
for user in joan jennie james jim jimbob johnboy ; do # or other file list
DESCRIPTION="Mail archive for $user"
TARBALL="${DIR}/${user}.tar.bz2"
if [ -r $TARBALL ] ; then
SHASUM=$($TREEHASH $TARBALL)
echo "uploading ${TARBALL} with checksum ${SHASUM}"
/usr/local/bin/aws glacier upload-archive --account-id $ACCOUNT --vault-name $VAULT --checksum ${SHASUM} --body $TARBALL
else
echo "could not read $TARBALL"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment