Last active
December 23, 2015 01:09
-
-
Save kechol/6558661 to your computer and use it in GitHub Desktop.
simple mysqldump script with RDS & S3
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
| #!/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