Created
November 24, 2013 18:39
-
-
Save awaxa/7630665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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