Skip to content

Instantly share code, notes, and snippets.

@seventhskye
Created June 7, 2016 12:34
Show Gist options
  • Save seventhskye/e3d37c498a89f8a25577c01a65d5053d to your computer and use it in GitHub Desktop.
Save seventhskye/e3d37c498a89f8a25577c01a65d5053d to your computer and use it in GitHub Desktop.
Script to upload or download a current working directory to an s3 bucket. Script assumes that the present working directory will be the name of the s3 directory
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $@ upload|download"
if [ "$BUCKET_NAME" == "" ]; then
echo "variable \$BUCKET_NAME name must be set."
fi
else
DIR=`basename ${PWD}`
aws configure --profile cloud-backup
if [ "$1" == "upload" ]; then
aws s3 sync . s3://$BUCKET_NAME/$DIR
fi
if [ "$1" == "download" ]; then
aws s3 sync s3://$BUCKET_NAME/$DIR .
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment