I try to write a script that exporting some of the tables of a multi-site WordPress in shell script.
In my shell script, I start by retrieving the blogs IDs and the slug of each blog, and after some text processing I have a file that seems like that:
The file located under a folder called tmp
in my working directory and the file name is blogs.csv
1,root-site
2,another-size
...
6,last-size
after that, I use the following code to iterate among the lines of that file and get the values from each line accordingly:
while IFS=',' read -r ID Slug; do
# Iteration code here
done < "./tmp/blogs.csv"
IFS=$' \t\n'
Inside the loop, I have my code that producing the mysqldump
command that extracting the required tables, and finally, after the command get produced I execute the following command to export the tables:
export_data="mysqldump -uroot -proot --opt ${schema} ${tables} > ${Slug}.sql"
sudo vagrant ssh --command "cd $export_folder && $export_data"
Now, white all information is correct, the script get's executed only once, and if I comment out the following line:
sudo vagrant ssh --command "cd $export_folder && $export_data"
Then the script executed for all blogs in my site.
So the question is, can I execute vagrant ssh --command
more than once in a certain amount of time ? Do you think, is there any solution for that ?
UPDATE #1
In my mysqldump
string I have add the option --debug-info and the result is the following:
Warning: Using a password on the command line interface can be insecure.
Connection to 127.0.0.1 closed.
Warning: Using a password on the command line interface can be insecure.
User time 0.00, System time 0.00
Maximum resident set size 2576, Integral resident set size 0
Non-physical pagefaults 860, Physical pagefaults 0, Swaps 0
Blocks in 0 out 1712, Messages in 0 out 0, Signals 0
Voluntary context switches 57, Involuntary context switches 49
Additionally if you see, in my log I have two Warning:
messages, but not two Connection to 127.0.0.1 closed.
messages, that means something wrong goes on with mysql dump ? I don't know. Can somebody help me ?