Created
April 26, 2017 13:22
-
-
Save damuz91/8407cf91436dd11f99bc5e33847b9415 to your computer and use it in GitHub Desktop.
Script for auto backing up a mysql db, gzip it and upload to Amazon 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/bash | |
DBNAME=mydb | |
USER="david" | |
PASSWORD='mypassword123' | |
DATE=`date +"%Y%m%d"` | |
SQLFILE=$DBNAME-${DATE}.sql | |
BUCKETNAME=my-aws-bucket-name | |
cd | |
echo "Starting with the following data:" | |
echo $DBNAME | |
echo $USER | |
echo $PASSWORD | |
mysqldump --force --opt --user=$USER --password=$PASSWORD --databases $DBNAME > $SQLFILE | |
gzip $SQLFILE | |
s3cmd put $DBNAME-${DATE}.sql.gz s3://$BUCKETNAME/$DBNAME-${DATE}.sql.gz | |
rm $SQLFILE.gz | |
echo "Finished it" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment