6

I'm using RARLABS RAR.exe to archive/backup my server data. I am familiar with using RAR for creating an archive and adding files from a folder, but what about streaming data directly into an archive?

For example, when backing up my MySQL databases I use the mysqldump command that includes a pipe command into a text file. It would be nice to skip the file step and go directly into an archive file using something like the following syntax:

mysqldump -uUserName -pPassword --all-databases > rar.exe newarchivename.rar

Does anyone know if what I have described, or something similar, is even possible?

Dscoduc
  • 1,095
  • 2
  • 8
  • 15

2 Answers2

14

I contacted RARLabs support and recieved a response. It turns out that RAR.EXE can handle streaming input similar to how gzip works. You just need to specify the -si option:

   -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.

Why would I want to use RAR instead of GZIP? Well one thing GZIP doesn't have is the ability to automatically include a date stamp on the file name.

So with this info here is an example of how I will be backing up the MySQL database information:

mysqldump --all-databases | rar a -siWordPressDB.sql -ag_MMMDDYYYY-HHMM WordPressDB.sql.rar

Which creates an archive file that looks similar to the following name:

WordPressDB.sql_Feb242010-0938.rar

and contains a single file:

WordPressDB.sql

Pretty cool...

Dscoduc
  • 1,095
  • 2
  • 8
  • 15
  • nice, didn't know it could do that (none of my versions of rar support the -si option.. time to upgrade) – James Feb 24 '10 at 19:07
0

Thanks, exactly what I'm looking for, this makes rar much more usefull.

nice, didn't know it could do that (none of my versions of rar support the -si option.. time to upgrade) – James Feb 24 at 19:07

This function is at least available since v3.71

For some reason this function isn't in the manual.
You can find this information and more in the rar.txt file.
(*nix) Usually in /usr/share/doc/rar (rar.txt or rar.txt.gz)