tmp file contains:
database_1
database_2
database_3
I want to run the command "mysqldump DATABASE> database.sql && gzip database.sql" for each line in the above file.
I got to cat / tmp / database-list | xargs -L 1 mysqldump -u root -p
I suppose I want to know how to transfer data passed to xargs several times (and not just to the end)
EDIT: the following command will delete each database in its own .sql file and then gzip.
mysql -u root -pPASSWORD -B -e 'show databases' | sed -e '$!N; s/Database\n//' | xargs -L1 -I db mysqldump -u root -pPASSWORD -r db.backup.sql db; gzip *.sql
source
share