# LVREMOVE-PATH
# VGDISPLAY-PATH
#
+# STABLE-MOUNTPOINT
# SUDO
#
use lib '@@PERL_VENDORARCH@@';
use Config;
use File::Temp qw(tempdir);
+use File::Path qw(make_path);
use IPC::Open3;
use Symbol;
+use Digest::MD5 qw(md5_hex);
sub new {
my $class = shift;
my ($execute_where, $config, $host, $disk, $device, $level, $index,
$message, $collection, $record, $snapsize, $lvcreate, $lvdisplay,
- $lvremove, $vgdisplay, $blkid, $sudo) = @_;
+ $lvremove, $vgdisplay, $blkid, $stablemount, $sudo) = @_;
my $self = $class->SUPER::new($execute_where, $config);
$self->{execute_where} = $execute_where;
$self->{vgdisplay} = $vgdisplay;
$self->{blkid} = $blkid;
+ $self->{stablemount} = $stablemount;
$self->{sudo} = $sudo;
$self->{volume_group} = undef;
}
# create a temporary mount point and mount the snapshot volume
- $self->{directory} = tempdir(CLEANUP => 0);
+ if ($self->{stablemount}) {
+ $self->{directory} = File::Spec->tmpdir . "/" . md5_hex($self->{disk});
+ make_path($self->{directory});
+ } else {
+ $self->{directory} = tempdir(CLEANUP => 0);
+ }
my $snapshot_device = $self->get_snap_device(0);
$self->execute(1,
"mount -o ", join(",", @options),
my $real_device = $self->readlink($device);
chomp($real_device);
- if ($real_device eq $mnt_device) {
+ if (($device eq $mnt_device) || ($real_device eq $mnt_device)) {
$self->{device} = $device;
$self->{volume_group} = $group;
$self->{fs_type} = $fs_type;
sub usage {
print <<EOF;
-Usage: amlvm-snapshot <command> --execute-where=client --config=<config> --host=<host> --disk=<disk> --device=<device> --level=<level> --index=<yes|no> --message=<text> --collection=<no> --record=<yes|no> --snapshot-size=<lvm snapshot size> --lvcreate-path=<path> --lvdisplay-path=<path> --lvremove-path=<path> --vgdisplay-path=<path> --blkid-path=<path> --sudo=<0|1>.
+Usage: amlvm-snapshot <command> --execute-where=client --config=<config> --host=<host> --disk=<disk> --device=<device> --level=<level> --index=<yes|no> --message=<text> --collection=<no> --record=<yes|no> --snapshot-size=<lvm snapshot size> --lvcreate-path=<path> --lvdisplay-path=<path> --lvremove-path=<path> --vgdisplay-path=<path> --blkid-path=<path> --stable-mountpoint=<0|1> --sudo=<0|1>.
EOF
exit(1);
}
my $opt_lvremove;
my $opt_vgdisplay;
my $opt_blkid;
+my $opt_stablemount;
my $opt_sudo;
Getopt::Long::Configure(qw{bundling});
'lvremove-path=s' => \$opt_lvremove,
'vgdisplay-path=s' => \$opt_vgdisplay,
'blkid=s' => \$opt_blkid,
+ 'stable-mountpoint=s' => \$opt_stablemount,
'sudo=s' => \$opt_sudo,
) or usage();
my $script = Amanda::Script::Amlvm_snapshot->new($opt_execute_where,
$opt_config, $opt_host, $opt_disk, $opt_device, \@opt_level, $opt_index,
$opt_message, $opt_collection, $opt_record, $opt_snapsize, $opt_lvcreate,
- $opt_lvdisplay, $opt_lvremove, $opt_vgdisplay, $opt_blkid, $opt_sudo);
+ $opt_lvdisplay, $opt_lvremove, $opt_vgdisplay, $opt_blkid, $opt_stablemount, $opt_sudo);
$script->do($ARGV[0]);
# vim: set et sts=4 sw=4 :