-
-
Save harshamv/d4dcd61c9b41f0e9d835 to your computer and use it in GitHub Desktop.
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 | |
# mongodump reference: http://www.nacaolivre.com.br/servidor/mysql-backup-com-mysqldump/ | |
# Author: Lazaro Lima - www.lazarolima.com.br | |
# | |
S3_BUCKET_NAME="condomundo-databases-snapshots" | |
S3_BUCKET_PATH="mysql-backups" | |
MYSQLROOT="yourUserName" | |
MYSQLPASS="yourPassword" | |
# Array of Databases | |
#example >>>> DBS=("<db1>" "<db2>" "<db3>" "<db4>") | |
DBS=("database_name") #database name is case sentitive | |
for i in "${DBS[@]}" | |
do | |
DBNAME=$i | |
echo "Backing up $DBNAME..." | |
FILE=$DBNAME-`date "+%Y%m%d-%H%M"`.sql.gz | |
mysqldump $DBNAME --user=$MYSQLROOT --password=$MYSQLPASS | gzip -9> /home/$FILE | |
echo "FILE: /home/$FILE created successfully" | |
echo "sending to s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/ ..." | |
s3cmd put /home/$FILE s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/ >> /var/log/mysqlbackup.log | |
sleep 5 | |
echo "removing /home/$FILE" | |
rm /home/$FILE | |
echo "$DBNAME backup complete!" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment