!/bin/bash MUSER="root" MPASS="" read -s -p "MYSQL PASSWORD:" MPASS MHOST="localhost" MYSQL="$(which mysql)" MYSQLDUMP="$(which mysqldump)" BAK="/usr/local/backup/full_mysql/mysql" ! [ -d $BAK ] && mkdir $BAK ! [ -d $BAK ] && exit GZIP="$(which gzip)" NOW=$(date +"%Y-%m-%d") DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')" for db in $DBS do echo backup $db ... FILE=$BAK/$db.$NOW-$(date +"%T").gz $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE done
No hay comentarios:
Publicar un comentario