If you really want to use
zip, you can use Jeff Schaller’s trick:
mysqldump -u root -p --all-databases | zip "$drt/db-$date.zip" -
This will create a ZIP file containing a file named
- whose contents are the database dump. This is mentioned in the
zip also accepts a single dash ("-") as the name of a file to be compressed, in which case it will read the file from standard
input, allowing zip to take input from another program. For example:
tar cf - . | zip backup -
You could also use
mysqldump -u root -p --all-databases | zip -FI "$drt/db-$date.zip" /dev/stdin
This would result in an archive containing a file named
dev/stdin which might be harder to handle properly.
- is a common short-hand to tell programs to use standard input or output; it’s not something that the shell handles, it has to be supported by each individual program.
In both cases you’d probably want to use
funzip to extract the data; it extracts the first member of an archive to its standard output.