Dekoratives Bildchen

Using STDIN/STDOUT streaming with rar instead of gzip/bzip2

I found it annoying for a long time, that i have only single threaded compress programs under linux when using compress from stdin.
Today i noticed a command line switch for rar which enables this for rar.

   -si[name]
     Read data from stdin (standard input), when creating
     an archive. Optional 'name' parameter allows to specify
     a file name of compressed stdin data in the created
     archive. If this parameter is missing, the name will be
     set to 'stdin'. This switch cannot be used with -v.

Now i can replace my MySQL Database Backup like this

[old]# mysqldump bigdb | bzip2 -c > bigdb.sql
[new]# mysqldump bigdb | rar a -sibigdb.sql bigdb.sql.rar

To uncompress to stdout the commands change like the following:
Das Entpacken nach stdout funktioniert dann wie folgt:

[old]# bzcat bigdb.sql.bz2 | mysql bigdb
[new]# rar -inul p bigsb.sql.rar bigdb.sql | mysql bigdb

Leave a Reply