deal with several backup dirs.

This commit is contained in:
hjp 2008-07-15 21:17:14 +00:00
parent a06a715c5d
commit 54c4472a16
1 changed files with 15 additions and 0 deletions

15
backup
View File

@ -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();