mysqldump 脚本

  • 安装schema分每个文件导出
    • #!/bin/env bash
      DB_USER=dbxx
      DB_PASSWORD=dbxx
      BACKUP_DIR=/opt/mysql_bak/
      for i in `/usr/local/mysql/bin/mysql  -u$DB_USER -p$DB_PASSWORD -BN -e"show databases;" |sed '/^performance_schema$/'d|sed '/^sys$/'d|sed '/^information_schema$/'d|sed '/^test$/'d|sed '/^sysdb$/'d `
      do
      /usr/local/mysql/bin/mysqldump -u$DB_USER -p$DB_PASSWORD --set-gtid-purged=OFF --master-data=2 -q -c --single-transaction --triggers -R -E -B $i > $BACKUP_DIR/schemas/$i.sql
      done
      

        

posted @ 2022-11-22 13:57  Jiangqiang  阅读(31)  评论(0编辑  收藏  举报