标签:企业 shell name -- grep font base egrep zip
分库备份
企业实战题7:如何实现对MySQL数据库进行分库备份,请用脚本实现
#!/bin/bash MysqlUser=root PassWord=root Port=3306 Socket="/usr/include/mysql/mysql.sock" MysqlCmd="mysql -u$MysqlUser -p$PassWord -S $Socket" Database=`$MysqlCmd -e "show databases;"|egrep -v "Database|_schema|mysql"` MysqlDump="mysqldump-u$MysqlUser -p$PassWord -S $Socket" IP=`ifconfig enp0s3|grep "broadcast"|awk ‘{print $NF}‘` //centos 7 BackupDir=/backup/$IP [ -d $BackupDir ] || mkdir -p$BackupDir for dbname in $Database do $MysqlDump --events -B $dbname|gzip>/$BackupDir/${dbname}_$(date +%F)_bak.sql.gz done
标签:企业 shell name -- grep font base egrep zip
原文地址:http://www.cnblogs.com/sunziying/p/6556504.html