Sample Header Ad - 728x90

Incomplete MysqlDump Files - Mysqldump Inside For Loop

0 votes
1 answer
353 views
I am running a Windows 10 Machine with WAMP installed. I have also a Git Bash Installed. I was trying to backup all my databases in each separate file using the code below. for DB in $(mysql -uroot -proot -e 'show databases'); do mysqldump -uroot -proot --complete-insert $DB > "$DB".sql; done; The Problem is I am **only getting incomplete dump files** for all databases **except the last one. The last dump is complete.** I have tried gzip the sql file by the following command for DB in $(mysql -uroot -proot -e 'show databases'); do mysqldump -uroot -proot --complete-insert $DB > "$DB".sql; [[ $? -eq 0 ]] && gzip "$DB".sql; done; Got the same result. Only the last database is getting dumped and gzipped completely. Note: It seems the next iteration happens before the previous finishes. I have tried using wait and sleep inside but nothing works. I have also tried using mysqldump options --single-transaction, --force, --quick but none seem to work.
Asked by Harish ST (103 rep)
Nov 16, 2019, 05:20 AM
Last activity: Nov 16, 2019, 12:29 PM