On Mon, Oct 04, 2010 at 03:32:23PM -0400, Timothy J Massey wrote:
> Robin Lee Powell <rlpow...@digitalkingdom.org> wrote on 10/04/2010
> 03:28:23 PM:
> 
> > On Mon, Oct 04, 2010 at 03:25:03PM -0400, Timothy J Massey
> > wrote:
> > > Robin Lee Powell <rlpow...@digitalkingdom.org> wrote on
> > > 10/04/2010 03:15:29 PM:
> > > 
> > > > How do I find out which backups are using a lot of disk?
> > > > We'd like to see if there's a problem with our retention
> > > > policy, especially on database servers, but I've no insight
> > > > at all into where all this disk is *going*.
> > > > 
> > > > Anyone got a script for this?
> > > 
> > > I don't have a script for this, but if you look at the host
> > > page for each server, examine the "New Files" section.  This
> > > will tell you which backups are consuming a lot of space (i.e.
> > > aren't pooling well).
> > 
> > We have 200+ servers getting backed up on here.  :)
> 
> Well, then, you'll want to parse the pc/<hostname>/backups file.
> The 9th (New Files Count) and 10th (New Files Size) field (AFAICT)
> are what you're looking for.
> 
> Sorry, no script.

I've got one.  Attached.  Specialized for our environment, not
productionalized or anything, but it works.

-Robin

-- 
http://singinst.org/ :  Our last, best hope for a fantastic future.
Lojban (http://www.lojban.org/): The language in which "this parrot
is dead" is "ti poi spitaki cu morsi", but "this sentence is false"
is "na nei".   My personal page: http://www.digitalkingdom.org/rlp/
#!/usr/bin/perl


use strict;
use warnings;
use Data::Dumper;

chdir '/backups/pc';

opendir(DIR, '.') || die "can't opendir . $!";
my @dirs = grep { ! /^\./ } readdir(DIR);
closedir DIR;

my %values;

foreach my $dir (@dirs) {
        open( BACKUPS, "<$dir/backups" ) || do {
                print "Could not open file /backups/pc/$dir/backups \n";
                next;
        };

        my $total_total=0;
        my $new_total=0;
        my $num_backups=0;
        while( <BACKUPS> ) {
                my @fields = split( /\t/ );

                if( $fields[5] =~ /^\d+$/ && $fields[9] =~ /^\d+$/ ) {
                        # THe total size for this backup
                        $total_total += $fields[5];
                        # Minus what was already there
                        $total_total -= $fields[7];
                        # THe new/additional size for this backup
                        $new_total += $fields[9];
                        $num_backups++;
                }
        }
        close( BACKUPS );

        $values{$dir} = {
                total => $total_total,
                new => $new_total,
                num => $num_backups,
        }
}

print q{
                                                                   Total New 
Size    Average New Size Per Backup
Backup Name                                            Total Size         
Number Of Backups
};

foreach my $key (sort { $values{$b}->{total} <=> $values{$a}->{total} } keys 
%values) {
#       printf( "Backup $key has %20.2d GiB of backups on disk total.\n", ( 
($values{$key}->{total}) / 1024 / 1024 / 1024 ) );
my $total_gib=( ($values{$key}->{total}) / 1024 / 1024 / 1024 );
my $new_gib=( ($values{$key}->{new}) / 1024 / 1024 / 1024 );
my $num_backups=$values{$key}->{num};
my $avg_new_mib=( ( ($values{$key}->{new}) / $num_backups ) / 1024 / 1024 / 
1024 );
 format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   @####.## GiB @####.## 
GiB @## @####.#### GiB
$key, $total_gib, $new_gib, $num_backups, $avg_new_mib
.
write;
}

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

Reply via email to