I can't get this batch file to work piping the mysqldump output to gzip. However doing it in two separate lines does work, so where am I doing it wrong please?
set dbUser=root
set dbPassword=mypassword
set mysqldump="C:\xampp\mysql\bin\mysqldump.exe"
set gzip="C:\Program Files\7-Zip\7z.exe"
:: do the database dump -this works!
:: %mysqldump% --host=localhost --user=%dbUser% --password=%dbPassword% %DBNAME% --single-transaction --hex-blob --routines --triggers --all-databases > C:\temp\MySQL-ALL-DATABASES.sql
:: then GZIP it
:: this line works too!
:: %gzip% a -tgzip C:\temp\MySQL-ALL-DATABASES.sql.gz C:\temp\MySQL-ALL-DATABASES.sql
:: BUT replace above with one line does NOT work?? gives "mysqldump write error 22"
%mysqldump% --host=localhost --user=%dbUser% --password=%dbPassword% %DBNAME% --single-transaction --hex-blob --routines --triggers --all-databases | %gzip% > C:\temp\MySQL-ALL-DATABASES.sql.gz
cmdline for the one-liner reads:
"C:\xampp\mysql\bin\mysqldump.exe" --host=localhost --user=root --password=mypassword --single-transaction --hex-blob --routines --triggers --all-databases | "C:\Program Files\7-Zip\7z.exe" 1>C:\temp\MySQL-ALL-DATABASES.sql.gz