Skip to content

Instantly share code, notes, and snippets.

@kechol
Last active December 23, 2015 01:09
Show Gist options
  • Select an option

  • Save kechol/6558661 to your computer and use it in GitHub Desktop.

Select an option

Save kechol/6558661 to your computer and use it in GitHub Desktop.
simple mysqldump script with RDS & S3
#!/bin/sh
# required: https://github.com/aws/aws-cli
date=`date "+%Y%m%d-%H:%M:%S"`
user=<rds-user>
host=<rds-host>
db=<rds-database>
s3bucket=<s3-bucket>
s3region=<s3-region>
export AWS_ACCESS_KEY_ID=<aws-access-key-id>
export AWS_SECRET_ACCESS_KEY=<aws-access-secret>
mkdir -p $host
mysqldump -h $host -u $user -p --all-databases --skip-lock-tables --debug-info > $host/$user_$db_$date.sql
aws s3 ls s3://$s3bucket --region=$s3region
aws s3 cp $host/$user_$db_$date.sql s3://$s3bucket/$user_$db_$date.sql --region=$s3region
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment