Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- export S3BUCKET=thebenchapp/db_backups
- export MYSQLDUMP=/usr/bin/mysqldump
- export MYSQL=/usr/bin/mysql
- export CMDS3=/usr/bin/s3cmd
- export CMDGZIP=/bin/gzip
- export USER=root
- export PASSWORD=Password!
- export DBTIMESTAMP=`date '+%m-%d-%Y_%H'`
- export DBNAME=scienceexchange_production
- export DBNAMEBAK=scienceexchange_production_bak
- export STORAGEPATH=/home/scienceexchange/www/production/db_backups
- # backup the productino db
- $MYSQLDUMP -u $USER -p$PASSWORD $DBNAME | $CMDGZIP > $STORAGEPATH/$DBNAME_$DBTIMESTAMP.sql.gz
- # dump the file to S3
- $CMDS3 put $STORAGEPATH/$DBNAME_$DBTIMESTAMP.sql.gz s3://$S3BUCKET/$DBNAME_$DBTIMESTAMP.sql.gz
- # restore to a backup db
- $GZIP < $STORAGEPATH/$DBNAME_$DBTIMESTAMP.sql.gz | $MYSQL -u $USER -p$PASSWORD $DBNAMEBAK
Add Comment
Please, Sign In to add comment