Mysql数据库导出压缩并保存到指定位置备份脚本

#!/bin/bash
backdir=/home/shaowei/dbbak
dbuser='dbusername'
dbpass='dbpasswd'
dblist=$(ls -p /var/lib/mysql | grep / | tr -d /)
today=$(date +%Y%m%d)
mkdir $backdir
mkdir $backdir/$today
for dbname in $dblist
do mysqldump -u$dbuser -p$dbpass $dbname | gzip -v > $backdir/$today/$dbname-$today.sql.gz
echo $dbname 'OK'
done

上一篇:css样式表的知识点总结


下一篇:iOS 9 强制横屏