Try to find all devices suitable for backup and mount them.
This commit is contained in:
parent
74da594a66
commit
c0254d8f53
20
backup
20
backup
|
@ -5,6 +5,7 @@ use Simba::CA;
|
|||
use POSIX qw(strftime);
|
||||
use Getopt::Long;
|
||||
use Filesys::Statvfs;
|
||||
use File::stat;
|
||||
|
||||
my @filesets;
|
||||
|
||||
|
@ -24,6 +25,25 @@ my $ca = Simba::CA->new({
|
|||
});
|
||||
$ca->log_level(9);
|
||||
|
||||
# Try to find all devices suitable for backup and mount them.
|
||||
# We do this by trying to find a matching device for each subdirectory
|
||||
# of /backup. Another way might be to check all USB disks.
|
||||
my $st = stat("/backup/");
|
||||
my $base_device = $st->dev;
|
||||
for (glob("/backup/*")) {
|
||||
my $st = stat($_);
|
||||
my $dir_device = $st->dev;
|
||||
if ($base_device == $dir_device) {
|
||||
# not a mount point
|
||||
(my $basedir = $_) =~ s{^/backup/}{};
|
||||
if (-e "/dev/disk/by-id/$basedir") {
|
||||
# matching device exists
|
||||
system("/bin/mount", "-o", "nodev,noexec,nomand,nosuid", "/dev/disk/by-id/$basedir", $_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# find the backup dir with the most free space available.
|
||||
# other strategies are possible, like round robin, or daily, weekly,
|
||||
# etc. backups.
|
||||
|
|
Loading…
Reference in New Issue