Skip to content

Instantly share code, notes, and snippets.

@jpbarbosa
Last active June 25, 2016 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpbarbosa/3fe4d73a1d368e1ee90d9200c05a95df to your computer and use it in GitHub Desktop.
Save jpbarbosa/3fe4d73a1d368e1ee90d9200c05a95df to your computer and use it in GitHub Desktop.
Script to backup S3 buckets based on local directories
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