mysql批量备份脚本

如何实现自动备份数据路里面所有业务表的功能:

#!/bin/bash
echo "Dump mysql databases..."

DB_USER=xxx
DB_PASSWORD=xxx

DB_LIST=$(echo "show databases;" | mysql -u${DB_USER} -p${DB_PASSWORD})
for db in ${DB_LIST}
do
  if [ $db != "Database" ] && [ $db != "mysql" ] &&
      [ $db != "phpmyadmin" ] && [ $db != "information_schema" ] &&
      [ $db != "performance_schema" ]; then
    echo "  backup "$db
    mysqldump -u${DB_USER} -p${DB_PASSWORD} $db > ./$db.sql
  fi
done

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注