Last active
August 29, 2015 14:12
-
-
Save StudioLE/6ca7576ec866c9df7104 to your computer and use it in GitHub Desktop.
Backup MySQL and upload to S3
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
#!/bin/bash | |
echo "LE Database Backup Wizard v2" | |
echo "Which database would you like to backup? [\"n\" to abort]" | |
read database | |
if [ $database = n ] | |
then | |
echo "Aborted" | |
exit | |
fi | |
conf="/srv/lib/backups/sql/mysql.conf" | |
name=$database"-"$(date +"%F-%H-%M") | |
sql="/srv/lib/backups/sql/"$name".sql" | |
echo "Backing up database.." | |
mysqldump --defaults-file=$conf $database > $sql | |
echo "Database backed up" | |
echo "Would you like to copy the sql to S3? [y/n]" | |
read s3 | |
if [ $s3 = n ] | |
then | |
echo "Aborted" | |
exit | |
fi | |
echo "Uploading to S3.." | |
aws s3 cp $sql s3://le-uno/sql/ | |
echo "Uploaded "$name" to S3" |
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
[mysqldump] | |
user=USERNAME | |
password=PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment