zhaobei / Question-bank

此项目记录了日常遇到的问题与解决问题的过程
MIT License
0 stars 0 forks source link

批量备份数据库脚本 #7

Open zhaobei opened 2 years ago

zhaobei commented 2 years ago

`host=127.0.0.1 port=3306 user=root pwd=123456

databaseList=mysql -h$host -P$port -u$user -p$port -e "show databases" | awk '{print $1}'|xargs

for database in $databaseList; do if [ $database == "mysql" ]; then continue fi if [ $database == "Database" ]; then continue fi if [ $database == "destination_data" ]; then continue fi if [ $database == "performance_schema" ]; then continue fi if [ $database == "sys" ]; then continue fi if [ $database == "information_schema" ]; then continue fi mysqldump -h$host -P$port -u$user -p$pwd $database > $database.sql DATE_N=date "+%Y-%m-%d %H:%M:%S" echo "$DATE_N $database sucessed." sleep 1 done`