Created
April 13, 2017 14:43
-
-
Save scottlinux/3c470e221fc38b2cae67b40a7d2a33a9 to your computer and use it in GitHub Desktop.
Copy list of AWS S3 buckets into one S3 bucket
This file contains hidden or 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 | |
# Copy contents of many s3 buckets into a single | |
# archive bucket | |
# | |
# Run via an ec2 instance | |
set -e | |
set +x | |
# Optionally obtain list of bucket names via | |
# $ aws s3 ls | awk '{print $3}' | |
s3source=( abucket | |
anotherbucket | |
another-cool-bucket | |
sweet-prod-bucket | |
old-testing-bucket | |
test-temp-bucket | |
other-bucket-name ) | |
s3dest=cool-archive-bucket/optional-extra-path | |
for i in "${s3source[@]}"; do | |
aws s3 sync s3://$i s3://$s3dest/$i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment