#!/usr/bin/perl -T use warnings; use strict; use Simba::CA; use POSIX qw(strftime); use Getopt::Long; use Filesys::Statvfs; my @filesets; GetOptions('filesets=i' => \@filesets); @filesets = split(/,/,join(',',@filesets)); $ENV{PATH} = "/usr/bin"; my $now = strftime('%Y-%m-%dT%H:%M:%S', localtime()); open(my $log, '>>', '/var/log/simba/ca.log.' . $now); $log->autoflush(1); my $ca = Simba::CA->new({ dbi_file => $ENV{SIMBA_DB_CONN} || "$ENV{HOME}/.dbi/simba", fh_log => $log, (@filesets ? ( filesets => \@filesets ) : ()), }); $ca->log_level(9); # find the backup dir with the most free space available. # other strategies are possible, like round robin, or daily, weekly, # etc. backups. my @backup_dirs = map { $_ = $1 if m{(.*)/.*}; # basedir and detaint my($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = statvfs($_); [ $_, $bsize * $bavail ] } glob("/backup/*/active"); @backup_dirs = sort { $b->[1] <=> $b->[0] } @backup_dirs; $ca->basedir($backup_dirs[0][0]); $ca->run();