1 From 79e25dc83bc234357cf3dbbfa6694e61abd30e6b Mon Sep 17 00:00:00 2001
2 From: Guillaume Delacour <gui@iroqwa.org>
3 Date: Tue, 14 Jul 2015 00:24:02 +0200
4 Subject: [PATCH] Update rsnapreport.pl utility script to work with rsync >=
5 3.1.0 stats and bytes changes.
8 utils/rsnapreport.pl | 32 +++++++++++++++++++-------------
9 1 file changed, 19 insertions(+), 13 deletions(-)
11 diff --git a/utils/rsnapreport.pl b/utils/rsnapreport.pl
12 index 2249566..83fb6ca 100644
13 --- a/utils/rsnapreport.pl
14 +++ b/utils/rsnapreport.pl
17 # this script prints a pretty report from rsnapshot output
18 # in the rsnapshot.conf you must set
21 # and add --stats to rsync_long_args
22 # then setup crontab 'rsnapshot daily 2>&1 | rsnapreport.pl | mail -s"SUBJECT" backupadm@adm.com
23 # don't forget the 2>&1 or your errors will be lost to stderr
24 @@ -41,14 +41,14 @@ ()
25 my $filest = $bkdata{$source}{'files_tran'};
26 my $filelistgentime = $bkdata{$source}{'file_list_gen_time'};
27 my $filelistxfertime = $bkdata{$source}{'file_list_trans_time'};
28 - my $bytes= $bkdata{$source}{'file_size'}/1000000; # convert to MB
29 - my $bytest= $bkdata{$source}{'file_tran_size'}/1000000; # convert to MB
30 + my $bytes = $bkdata{$source}{'file_size'}/1000000; # convert to MB
31 + my $bytest = $bkdata{$source}{'file_tran_size'}/1000000; # convert to MB
32 $source =~ s/^[^\@]+\@//; # remove username
34 + format BREPORTHEAD =
35 SOURCE TOTAL FILES FILES TRANS TOTAL MB MB TRANS LIST GEN TIME FILE XFER TIME
36 --------------------------------------------------------------------------------------------------------------------
39 + format BREPORTBODY =
40 @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>> @>>>>>>>>>> @#########.## @########.## @>>>>>>>>>>>> @>>>>>>>>>>>>>
41 $source, $files, $filest, $bytes, $bytest, $filelistgentime, $filelistxfertime
52 @@ -83,24 +83,30 @@ ($)
54 while($line = nextLine(\@rsnapout)){
55 # this means we are missing stats info
56 - if($line =~ /^[\/\w]+\/rsync/){
57 + if($line =~ /^[\/\w]+\/rsync/){
58 unshift(@rsnapout,$line);
59 push(@errors,"$source NO STATS DATA");
64 if($line =~ /^total size is\s+\d+/){ last; } # this ends the rsync stats record
65 - elsif($line =~ /Number of files:\s+(\d+)/){
66 + # Number of files: 1,325 (reg: 387, dir: 139, link: 799)
67 + elsif($line =~ /Number of files:\s+([\d,]+)/){
68 $bkdata{$source}{'files'}=$1;
69 + $bkdata{$source}{'files'}=~ s/,//g;
71 - elsif($line =~ /Number of files transferred:\s+(\d+)/){
72 - $bkdata{$source}{'files_tran'}=$1;
73 + # Number of regular files transferred: 1
74 + elsif($line =~ /Number of (regular )?files transferred:\s+([\d,]+)/){
75 + $bkdata{$source}{'files_tran'}=$2;
77 - elsif($line =~ /Total file size:\s+(\d+)/){
78 + # Total file size: 1,865,857 bytes
79 + elsif($line =~ /Total file size:\s+([\d,]+)/){
80 $bkdata{$source}{'file_size'}=$1;
81 + $bkdata{$source}{'file_size'}=~ s/,//g;
83 - elsif($line =~ /Total transferred file size:\s+(\d+)/){
84 + elsif($line =~ /Total transferred file size:\s+([\d,]+)/){
85 $bkdata{$source}{'file_tran_size'}=$1;
86 + $bkdata{$source}{'file_tran_size'}=~ s/,//g;
88 elsif($line =~ /File list generation time:\s+(.+)/){
89 $bkdata{$source}{'file_list_gen_time'}=$1;