Skip to content

Instantly share code, notes, and snippets.

@scottlinux
Created April 13, 2017 14:43
Show Gist options
  • Save scottlinux/3c470e221fc38b2cae67b40a7d2a33a9 to your computer and use it in GitHub Desktop.
Save scottlinux/3c470e221fc38b2cae67b40a7d2a33a9 to your computer and use it in GitHub Desktop.
Copy list of AWS S3 buckets into one S3 bucket
#!/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