#!/usr/bin/perl use lib "/usr/share/BackupPC/lib"; use BackupPC::Lib; use BackupPC::CGI::Lib; use POSIX; use List::Util qw(min); use Data::Dumper; # We need to switch to backuppc UID/GID my $uid = getuid(); my $gid = getgid(); my (undef,undef,$bkpuid,$bkpgid) = getpwnam('backuppc'); setuid($bkpuid) if ($uid ne $bkpuid); setgid($bkpgid) if ($gid ne $bkpgid); my $bpc = BackupPC::Lib->new(); my $hosts = $bpc->HostInfoRead(); my $mainConf = $bpc->ConfigDataRead(); print '^ Jeux de sauvegarde ^ Description ^ Fréquence (jours) ^ volume complète (Go) ^ Volume incrémental (Go) ^ Durée moyenne (minutes) ^' . "\n"; foreach my $host (sort keys %$hosts){ my $hostConf = $bpc->ConfigDataRead($host); my $conf = { %$mainConf, %$hostConf }; my @backups = $bpc->BackupInfoRead($host); my ($nb_bkp,$nb_full,$nb_incr,$size_full,$size_incr,$duration) = 0; foreach my $backup (@backups){ $nb_bkp += 1; $duration += $backup->{endTime} - $backup->{startTime}; if ($backup->{type} eq 'full'){ $nb_full += 1; $size_full = $backup->{size}; } else { $nb_incr += 1; } # The size of new files can be computed for full or incr $size_incr += $backup->{sizeNew}; } if ($nb_bkp > 0){ $duration = sprintf('%.0f', ($duration / 60) / $nb_bkp); $size_incr = sprintf('%.3f', ($size_incr / (1024 * 1024 * 1024)) / $nb_bkp); } $size_full = sprintf('%.3f', $size_full / (1024 * 1024 * 1024)); my $freq = ($conf->{BackupsDisable} == 0 ) ? ceil(min(($conf->{IncrPeriod}, $conf->{FullPeriod}))) : 'N/A'; print "|$host | | $freq | $size_full | $size_incr | $duration |\n"; }