Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Exclude DBs

Help
Anonymous
2012-06-30
2013-05-29

  • Anonymous
    2012-06-30

    I am having a bit of a brain fart and wondering if someone might be able to help out.

    I would like to have

    CONFIG_db_names=()[code]
    and then exclude certain databases in a "wildcard fashion"
    [code]
    CONFIG_db_exclude=( 'information_schema' 'lost+found' 'test' )
    CONFIG_db_exclude=("$CONFIG_db_exclude $( \
        mysql \
            --user="$CONFIG_mysql_dump_username" \
            --password="$CONFIG_mysql_dump_password" \
            --host="$CONFIG_mysql_dump_host" \
            --batch \
            --skip-column-names \
            -e "show databases" \
        | grep -P "_(dev|test)$" \
        | sed "s/\s/' '/g;s/^/'/;s/$/'/"
    )")
    [/code]
    Should provide a list of all databases that end in _dev AND _test
    What I get when I echo out CONFIG_db_exclude
    [code]
    information_schema, 'Users_dev' 'adas_dev' 'adas_test' 'audit_dev' 'audit_test' 'cemt_dev' 'cemt_test'
    [code]
    But these databases do not get excluded.