Skip to content

Instantly share code, notes, and snippets.

@awaxa
Created November 24, 2013 18:39
Show Gist options
  • Save awaxa/7630665 to your computer and use it in GitHub Desktop.
Save awaxa/7630665 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# 1: source directory, ex: /mnt/stuff/Pictures
# 2: s3 prefix, ex: s3://awaxa-archive/archive/Pictures
find "$1" -depth -type f -print0 | while read -d $'\0' file ; do
dirname=$(dirname "$file")
filename=$(basename "$file")
reldir="${dirname#$1}"
key="$2${reldir//[^A-Za-z0-9.\/]/_}/${filename//[^A-Za-z0-9.]/_}.gpg"
tempfile=$(mktemp --dry-run --tmpdir=/dev/shm)
gpg -e -r awaxa -o $tempfile "$file"
aws s3 cp $tempfile $key
rm $tempfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment