How to compress a mysql dump using 7z via a pipe?
First store the password in a file called .my.cnf
in the users home directory with the following format:
[mysqldump]
password=secret
Then, you have to use mysqldump
without the -p
flag to dump a mysql database (it now uses the password from the file):
mysqldump -u root database | 7z a -si backup.sql.7z
- The
a
flag of7z
adds to the archive -si
means to read from the standard input (from the anonymous pipe).