A
A
Alexander2017-11-28 17:20:32
MySQL
Alexander, 2017-11-28 17:20:32

Why are tables not excluded from MySQL dump?

Greetings, comrades, and I ask for help with such a problem.
I am writing a small bash script to backup a MySQL database using mysqldump and I want to exclude some of the database tables from the dump when passing a certain key to it. I go with the following steps:
1. I form a list of tables, write them to an array;
2. From the array I form the string ' "--ignore-table="db.table_1" --ignore-table="db.table_2" ... --ignore-table="db.table_n"'
3. I create a structure dump DB with the --no-data key
4. Depending on whether the key is passed, I run mysqldump either on a full backup or by adding the key from step 2 there:
- mysqldump -u user -pPASSWORD --database db --single- transaction
or
- mysqldump -u user -pPASSWORD --database db --single-transaction --ignore-table="db.table_1" --ignore-table="db.table_2" ... --ignore-table="db. table_n"
If you go through these steps by hand, everything works as it should: with the exception of tables, the work is fast, the dump size is about 250 MB (only configuration databases are backed up). However, the dump from the script always turns out to be complete, although I checked that all variables are formed correctly and contain the tables necessary to exclude. Below is a screenshot with the code, and here is a link to the code on the github (lines 258-305).
5a1d6fdea561b685090464.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-11-29
@asand3r

Decided, I think that the problem is in expanding the variable. Transferred to ${VAR} - it worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question