]> git.pld-linux.org Git - packages/rsnapshot.git/blob - bug-207.patch
- include rsnapreport.pl
[packages/rsnapshot.git] / bug-207.patch
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.
6
7 ---
8  utils/rsnapreport.pl | 32 +++++++++++++++++++-------------
9  1 file changed, 19 insertions(+), 13 deletions(-)
10
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
15 @@ -1,7 +1,7 @@
16  #!/usr/bin/env perl
17  # this script prints a pretty report from rsnapshot output
18  # in the rsnapshot.conf you must set
19 -# verbose >= 3
20 +# verbose >= 4
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
33 -format BREPORTHEAD =
34 +               format BREPORTHEAD =
35  SOURCE                          TOTAL FILES   FILES TRANS      TOTAL MB     MB TRANS   LIST GEN TIME  FILE XFER TIME
36  --------------------------------------------------------------------------------------------------------------------
37  .
38 -format BREPORTBODY =
39 +               format BREPORTBODY =
40  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>   @>>>>>>>>>> @#########.## @########.##   @>>>>>>>>>>>>  @>>>>>>>>>>>>>
41  $source,                        $files,       $filest,    $bytes,       $bytest,       $filelistgentime, $filelistxfertime
42  .
43 @@ -62,7 +62,7 @@ ($)
44         push(@$lines,$line);
45         return shift @$lines;
46  }
47 -       
48 +
49  
50  my @rsnapout = ();
51  
52 @@ -83,24 +83,30 @@ ($)
53                 #print $source;
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");
60 -                               last;  
61 +                               last;
62                         }
63                         # stat record
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;
70                         }
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;
76                         }
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;
82                         }
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;
87                         }
88                         elsif($line =~ /File list generation time:\s+(.+)/){
89                                 $bkdata{$source}{'file_list_gen_time'}=$1;
This page took 0.082785 seconds and 3 git commands to generate.