Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script de backup dos bancos MYSQL
- # data da ultima alteracao: 15/07/2016
- #
- ### MYSQL #####
- HORABKP=`date +"%d%m%Y-%Hh%Mm"`
- DBUSER="USER"
- DBPASS="PASSWORD";
- SERVER=`uname -n | cut -d\. -f1`
- DST="/BACKUP"
- # DELETE Backup 7 days old
- find $DST/ -mtime +7 -type f -delete
- # Array de Bancos x Tabelas
- if [ ! -f $HORABKP ]; then
- mysql -u$DBUSER -p$DBPASS -e "show databases" -s | grep -v Database | while read DB ;
- do
- if [ -d "/BACKUP/$DB" ]; then
- echo ""
- else
- mkdir -p /BACKUP/$DB
- echo "diretorio nao existe"
- fi
- mysql -u$DBUSER -p$DBPASS $DB -e "show tables " | grep -v Tables_in | while read TABLES ;
- do
- mysqldump $DB --no-create-db --tables $TABLES -p$DBPASS | gzip >> $DST/$DB/$SERVER-db-$DB-$TABLES-$HORABKP.sql.gz ;
- done
- done
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement