#!/bin/bashDate=`date -d 'today' +%Y%m%d`Date7=`date -d '7 days ago' +%Y%m%d`backdir='/data/mysqldump'mkdir -p $backdirfor i in `mysql --login-path=test -e "show databases" | grep -v test | grep -v information_schema | grep -v performance_schema | grep -v Database`do/usr/bin/mysqldump --login-path=test --single-transaction --master-data=2 --routines --flush-logs --flush-privileges --databases $i |gzip > $backdir/"$i"."$Date".sql.gzdonefind $backdir -name "*$Date7*.sql.gz" -exec rm -f {} \;