Last active
June 25, 2016 23:14
-
-
Save jpbarbosa/3fe4d73a1d368e1ee90d9200c05a95df to your computer and use it in GitHub Desktop.
Script to backup S3 buckets based on local directories
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
echo "Script to backup S3 buckets based on local directories" | |
echo "------------------------------------------------------------" | |
echo "" | |
for d in */ ; do | |
SECONDS=0 | |
BUCKET=`echo $d | sed 's/.$//'` | |
echo "------------------------------------------------------------" | |
echo "Bucket: $BUCKET" | |
source "$d.env" | |
echo "Profile: $PROFILE" | |
echo "Region: $REGION" | |
aws s3 sync s3://$d $d \ | |
--exclude "imagecache/*" \ | |
--region $REGION \ | |
--profile $PROFILE | |
echo "Creating tar file..." | |
tar -cf $BUCKET.tar $BUCKET | |
mv $BUCKET.tar ~/Dropbox/Static/ | |
duration=$SECONDS | |
echo "Done in $(($duration / 60)) min. and $(($duration % 60)) s." | |
echo "------------------------------------------------------------" | |
echo "" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment