标签:shel span rac backup nbsp password lis show cat
# cat /data/shell/mysqldump.sh
#!/bin/sh # Author: elisun IP=localhost USER=elisun PASSWORD=elisun BAKDB="test" MYSQLPATH=/usr/local/mysql/bin BACKDIR=/data/mysql_backup DATE=`date +%Y%m%d` if [ ! -e $BACKDIR ];then mkdir $BACKDIR fi for db in $BAKDB do MYSQLCHAR=`$MYSQLPATH/mysql -u$USER -h$IP -p$PASSWORD -e "show create database $db;" | awk ‘{print $9}‘ | tail -1` $MYSQLPATH/mysqldump -u$USER -h$IP -p$PASSWORD --default-character-set=$MYSQLCHAR $db > $BACKDIR/$db"_"$DATE.sql && echo "$MYSQLCHAR " echo "$db" cd $BACKDIR /bin/tar zcf $db"_"$DATE.tar.gz $db"_"$DATE.sql&&echo "$db tar success " done /usr/bin/find $BACKDIR -name "*.tar.gz" -mtime +5 -exec rm -f {} \; /usr/bin/find $BACKDIR -name "*.sql" -mtime +0 -exec rm -f {} \; ?
标签:shel span rac backup nbsp password lis show cat
原文地址:http://www.cnblogs.com/elisun/p/6880861.html