Formatting rsync output

Jim Salter jim at jrssystems.net
Mon Jul 19 00:27:30 GMT 2004


Use a perl script to fire off rsync.  If you need to output the rsync 
data as it comes in, you can use the "open" command:

open FH, "/usr/bin/rsync -avz /foo bar::baz 2>&1 |";
foreach (<FH>) {
    ### data parsing occurs here
}

Or if you don't mind waiting to parse the rsync output until rsync is 
completely done, you can just use backticks:

$rsync_output = `/usr/bin/rsync -avz /foo bar::baz`;
### parse $rsync_output here - you may want to use split to turn the 
string into a list, however
print $rsync_output;

Jim Salter
JRS Systems

>
>    When RSYNC runs in -v mode, I get the following output on, for 
> example, /etc:
>
> RSYNCing /etc ...    ( <--- this line is generated by the shell script)
> building file list ... done
> ./
> backup-daily.sh
> mail/statistics
> mtab
> wrote 26720 bytes  read 68 bytes  17858.67 bytes/sec
> total size is 4176073  speedup is 155.89
>
> RSYNCing /root ...   ( <--- this line is generated by the shell script)
> building file list ... done
> wrote 387 bytes  read 20 bytes  814.00 bytes/sec
> total size is 42133  speedup is 103.52
>
> etc., etc.
>
>
> I'm wondering if there's a way to format that data somehow.  Really 
> all I want to do is insert a tab infront of each RSYNC generated 
> line.  So the formatting with the rest of the script output is a bit 
> nicer to read.  Is this possible...somehow?
>



More information about the rsync mailing list