Last active
September 5, 2018 14:20
-
-
Save andreafalzetti/01135920dbc47fef9c0ffe6985858b76 to your computer and use it in GitHub Desktop.
Simple bash script to download and bundle an s3 bucket
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 | |
# Simple bash script to download and bundle an s3 bucket | |
# Usage: | |
# AWS_PROFILE=... S3_BUCKET_NAME=... ./s3bucket-to-tar | |
# Requires: | |
# aws cli, tar | |
set -euo pipefail | |
typeset -r DIR=$(cd "$(dirname "$0")" && pwd) | |
TMP_FOLDER=$(mktemp -d) | |
S3_BUCKET_NAME=${S3_BUCKET_NAME:-""} | |
aws s3 sync s3://$S3_BUCKET_NAME $TMP_FOLDER --quiet | |
DATE=`date +%Y-%m-%d` | |
OUTPUT=$DIR/$S3_BUCKET_NAME.tar.gz | |
tar czfP $OUTPUT $TMP_FOLDER | |
# Clean-up | |
rm -r $TMP_FOLDER | |
echo $OUTPUT | |
Author
andreafalzetti
commented
Sep 5, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment