write to random backup device, not the least full
This commit is contained in:
parent
f8856de2c9
commit
4aa78b8530
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/perl -T
|
#!/usr/bin/perl
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Simba::CA;
|
use Simba::CA;
|
||||||
|
@ -55,11 +55,22 @@ my @backup_dirs = map {
|
||||||
= statvfs($_);
|
= statvfs($_);
|
||||||
[ $_, $bsize * $bavail ]
|
[ $_, $bsize * $bavail ]
|
||||||
} glob("/backup/*/active");
|
} glob("/backup/*/active");
|
||||||
@backup_dirs = sort { $b->[1] <=> $a->[1] } @backup_dirs;
|
my $sum_free = 0;
|
||||||
unless (@backup_dirs) {
|
$sum_free += $_->[1] for (@backup_dirs);
|
||||||
|
my $rnd = rand() * $sum_free;
|
||||||
|
my $count_free = 0;
|
||||||
|
my $backup_dir;
|
||||||
|
for(@backup_dirs) {
|
||||||
|
$count_free += $_->[1];
|
||||||
|
if ($count_free >= $rnd) {
|
||||||
|
$backup_dir = $_->[0];
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unless ($backup_dir) {
|
||||||
$ca->log(0, "no backup directory found");
|
$ca->log(0, "no backup directory found");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
$ca->basedir($backup_dirs[0][0]);
|
$ca->basedir($backup_dir);
|
||||||
|
|
||||||
$ca->run();
|
$ca->run();
|
||||||
|
|
Loading…
Reference in New Issue