deal with several backup dirs.
This commit is contained in:
parent
a06a715c5d
commit
54c4472a16
15
backup
15
backup
|
@ -4,6 +4,7 @@ use strict;
|
|||
use Simba::CA;
|
||||
use POSIX qw(strftime);
|
||||
use Getopt::Long;
|
||||
use Filesys::Statvfs;
|
||||
|
||||
my @filesets;
|
||||
|
||||
|
@ -23,4 +24,18 @@ my $ca = Simba::CA->new({
|
|||
});
|
||||
$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();
|
||||
|
|
Loading…
Reference in New Issue