Created
March 28, 2019 07:00
-
-
Save rjeczalik/b31b531536adbaf6f297077ad6506861 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 | |
set -euo pipefail | |
bucket=${1} | |
mkdir -p ${bucket} | |
aws s3 ls ${bucket} | grep PRE | tr -s ' ' | cut -d' ' -f3 | while read snapshot_tag; do | |
snapshot_tag=${snapshot_tag%%/*} | |
echo "# $(date) reading backup metadata into ${bucket}/${snapshot_tag}.txt" >&2 | |
echo >&2 | |
aws s3api list-objects \ | |
--bucket ${bucket} \ | |
--prefix ${snapshot_tag} \ | |
--query 'Contents[].{Key: Key, ETag: ETag, Size: Size}' | | |
jq -r '.[] | .Key + "\t" + (.ETag | fromjson) + "\t" + (.Size | tostring)' > ${bucket}/${snapshot_tag%%/*}.txt | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment