Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Suffix added at the end of the filename
- NOW=$(date +"%d%m%Y")
- # Destination folder of all the dumps
- DEST="backups"
- # Set mysql login info
- MUSER="root"
- MPASS=""
- MHOST="127.0.0.1"
- # Guess binary names
- MYSQL="$(which mysql)"
- MYSQLDUMP="$(which mysqldump)"
- GZIP="$(which gzip)"
- [ ! -d "${DEST}" ] && mkdir -p "${DEST}"
- # Get all db names
- DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
- for db in $DBS
- do
- FILE=${DEST}/${db}_${NOW}.gz
- $MYSQLDUMP --single-transaction -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement