美文网首页
Skip certain tables with mysqldu

Skip certain tables with mysqldu

作者: 抽刀断水2 | 来源:发表于2018-05-08 20:52 被阅读0次
    #!/bin/bash
    PASSWORD=XXXXXX
    HOST=XXXXXX
    USER=XXXXXX
    DATABASE=databasename
    DB_FILE=dump.sql
    EXCLUDED_TABLES=(
    table1
    table2
    table3
    table4
    tableN   
    )
    
    IGNORED_TABLES_STRING=''
    for TABLE in "${EXCLUDED_TABLES[@]}"
    do :
       IGNORED_TABLES_STRING+=" --ignore-table=${DATABASE}.${TABLE}"
    done
    
    echo "Dump structure"
    mysqldump --host=${HOST} --user=${USER} --password=${PASSWORD} --single-transaction --no-data ${DATABASE} > ${DB_FILE}
    
    echo "Dump content"
    mysqldump --host=${HOST} --user=${USER} --password=${PASSWORD} ${DATABASE} --no-create-info ${IGNORED_TABLES_STRING} >> ${DB_FILE}
    

    相关文章

      网友评论

          本文标题:Skip certain tables with mysqldu

          本文链接:https://www.haomeiwen.com/subject/cizwrftx.html