Redirect --stats to STDERR.
LORAND Benoît
benoit.lorand at blorand.org
Wed Feb 7 17:48:48 GMT 2007
Aaron W Morris a écrit :
> On 2/7/07, LORAND Benoît <benoit.lorand at blorand.org> wrote:
>> Hello,
>>
>> I have written a little script that's would email me all errors.
>> rsync -vah --delete --stats <sources> <destination> >
>> /var/log/sauvegarde/listoffile.log 2> /var/log/sauvegarde/errors.log
>>
>> My problem is i want to have the stats in my mail. Is it possible to
>> redirect --stats to STDERR.
>>
>> I have tryed to do this :
>>
>> /--- rsync-2.6.9/main.c 2006-10-14
>> 01:46:32.000000000 +0200/
>> /+++ rsync-2.6.9.new/main.c 2007-02-06
>> 19:28:08.000000000 +0100/
>> /@@ -227,39 +227,39 @@/
>> / {/
>> / if (do_stats) {/
>> / rprintf(FCLIENT, "\n");/
>> /- rprintf(FINFO,"Number of files:
>> %d\n", stats.num_files);/
>> /- rprintf(FINFO,"Number of files
>> transferred: %d\n",/
>> /+ rprintf(FERROR,"Number of files:
>> %d\n", stats.num_files);/
>> /+ rprintf(FERROR,"Number of files
>> transferred: %d\n",/
>> /
>> stats.num_transferred_files);/
>> /- rprintf(FINFO,"Total file size: %s
>> bytes\n",/
>> /+ rprintf(FERROR,"Total file size: %s
>> bytes\n",/
>> /
>> human_num(stats.total_size));/
>> /- rprintf(FINFO,"Total transferred
>> file size: %s bytes\n",/
>> /+ rprintf(FERROR,"Total transferred
>> file size: %s bytes\n",/
>> /
>> human_num(stats.total_transferred_size));/
>> /- rprintf(FINFO,"Literal data: %s
>> bytes\n",/
>> /+ rprintf(FERROR,"Literal data: %s
>> bytes\n",/
>> /
>> human_num(stats.literal_data));/
>> /- rprintf(FINFO,"Matched data: %s
>> bytes\n",/
>> /+ rprintf(FERROR,"Matched data: %s
>> bytes\n",/
>> /
>> human_num(stats.matched_data));/
>> /- rprintf(FINFO,"File list size:
>> %d\n", stats.flist_size);/
>> /+ rprintf(FERROR,"File list size:
>> %d\n", stats.flist_size);/
>> / if (stats.flist_buildtime) {/
>> /- rprintf(FINFO,/
>> /+ rprintf(FERROR,/
>> / "File list
>> generation time: %.3f seconds\n",/
>> /
>> (double)stats.flist_buildtime / 1000);/
>> /- rprintf(FINFO,/
>> /+ rprintf(FERROR,/
>> / "File list transfer
>> time: %.3f seconds\n",/
>> /
>> (double)stats.flist_xfertime / 1000);/
>> / }/
>> /- rprintf(FINFO,"Total bytes sent:
>> %s\n",/
>> /+ rprintf(FERROR,"Total bytes sent:
>> %s\n",/
>> / human_num(total_written));/
>> /- rprintf(FINFO,"Total bytes
>> received: %s\n",/
>> /+ rprintf(FERROR,"Total bytes
>> received: %s\n",/
>> / human_num(total_read));/
>> / }/
>>
>> / if (verbose || do_stats) {/
>> / rprintf(FCLIENT, "\n");/
>> /- rprintf(FINFO,/
>> /+ rprintf(FERROR,/
>> / "sent %s bytes received %s
>> bytes %s bytes/sec\n",/
>> / human_num(total_written),
>> human_num(total_read),/
>> / human_dnum((total_written +
>> total_read)/(0.5 + (endtime - starttime)), 2));/
>> /- rprintf(FINFO, "total size is %s
>> speedup is %.2f\n",/
>> /+ rprintf(FERROR, "total size is %s
>> speedup is %.2f\n",/
>> /
>> human_num(stats.total_size),/
>> / (double)stats.total_size /
>> (total_written+total_read));/
>> / }/
>>
>>
>> But the problem is i have an error 23 when i use rsync.
>
> You could just pipe STDOUT and STDERR to the same file and email that
> to yourself. To prevent getting the list of files transfered, you
> could make rsync be quiet by removing -v and adding -q.
>
> rsync > out.log 2>&1
>
Yes but i would like to know what files have been up to date when my
save was done. it's why i use -v but this one wasn't mail to me. I just
mail errors.log
Is there an option for all files to be saved to an logfile ?
--
Benoît LORAND
http://www.blorand.org
benoit.lorand at blorand.org
More information about the rsync
mailing list