标签:mkdir class date ycm 编程 cmd databases log back
企业实战题8:如何实现对MySQL数据库进行分库备份,请用脚本实现
我的脚本=========================
#!/bin/bash BAKPATH=/server/backup MYUSER=root MYPASS=oldboy123 SOCKET=/data/3306/mysql.sock MYCMD="mysql -u$MYUSER -p$MYPASS -S$SOCKET" MYDUMP="mysqldump -u$MYUSER -p$MYPASS -S$SOCKET -x -B -F -R" [ ! -d $BAKPATH ] && mkdir -p $BAKPATH DBLIST=`$MYCMD -e "show databases;"|sec 1d |egrep -v "_schema|mysql"` for dbname in $DBLIST do $MYDUMP ${dbname}|gzip > ${BAKPATH}/${dbname}_$(date +%F).sql.gz done
合格linux运维人员必会的30道shell编程面试题及讲解-08
标签:mkdir class date ycm 编程 cmd databases log back
原文地址:http://www.cnblogs.com/oliver-blogs/p/7723324.html