#!@PERL@
-# Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
+# Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
+# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
# PROPERTY:
#
use lib '@amperldir@';
use strict;
+use warnings;
use Getopt::Long;
package Amanda::Script::Amzfs_snapshot;
sub new {
my $class = shift;
my ($execute_where, $config, $host, $disk, $device, $level, $index, $message, $collection, $record, $df_path, $zfs_path, $pfexec_path, $pfexec) = @_;
- my $self = $class->SUPER::new($execute_where);
+ my $self = $class->SUPER::new($execute_where, $config);
$self->{execute_where} = $execute_where;
$self->{config} = $config;
$self->{host} = $host;
- $self->{disk} = $disk;
- $self->{device} = $device;
+ if (defined $disk) {
+ $self->{disk} = $disk;
+ } else {
+ $self->{disk} = $device;
+ }
+ if (defined $device) {
+ $self->{device} = $device;
+ } else {
+ $self->{device} = $disk;
+ }
$self->{level} = [ @{$level} ]; # Copy the array
$self->{index} = $index;
$self->{message} = $message;
sub zfs_snapshot_set_value() {
my $self = shift;
- my $action = shift;
- $self->zfs_set_value($action);
+ $self->zfs_set_value();
+
+ if (!defined $self->{device}) {
+ return;
+ }
if (!defined $self->{mountpoint}) {
- $self->print_to_server($action, "$self->{disk} is not a directory", $Amanda::Script_App::ERROR);
+ $self->print_to_server("$self->{disk} is not a directory", $Amanda::Script_App::ERROR);
}
}
sub command_pre_dle_amcheck {
my $self = shift;
- $self->zfs_snapshot_set_value("check");
+ $self->zfs_snapshot_set_value();
+
+ if (!defined $self->{device}) {
+ return;
+ }
if ($self->{error_status} == $Amanda::Script_App::GOOD) {
if (defined $self->{mountpoint}) {
- $self->print_to_server("check", "mountpoint $self->{mountpoint}", $Amanda::Script_App::GOOD);
- $self->print_to_server("check", "directory $self->{directory}", $Amanda::Script_App::GOOD);
- $self->print_to_server("check", "dir $self->{dir}", $Amanda::Script_App::GOOD);
+ $self->print_to_server("mountpoint $self->{mountpoint}", $Amanda::Script_App::GOOD);
+ $self->print_to_server("directory $self->{directory}", $Amanda::Script_App::GOOD);
+ $self->print_to_server("dir $self->{dir}", $Amanda::Script_App::GOOD);
}
- $self->print_to_server("check", "snapshot $self->{snapshot}", $Amanda::Script_App::GOOD);
+ $self->print_to_server("snapshot $self->{snapshot}", $Amanda::Script_App::GOOD);
$self->zfs_create_snapshot("check");
print "PROPERTY directory $self->{directory}\n";
}
sub command_post_dle_amcheck {
my $self = shift;
- $self->zfs_snapshot_set_value("check");
+ $self->zfs_snapshot_set_value();
+
+ if (!defined $self->{device}) {
+ return;
+ }
+
$self->zfs_destroy_snapshot("check");
}
sub command_pre_dle_estimate {
my $self = shift;
- $self->zfs_snapshot_set_value("estimate");
+ $self->zfs_snapshot_set_value();
if ($self->{error_status} == $Amanda::Script_App::GOOD) {
$self->zfs_create_snapshot("estimate");
print "PROPERTY directory $self->{directory}\n";
sub command_post_dle_estimate {
my $self = shift;
- $self->zfs_snapshot_set_value("estimate");
+ $self->zfs_snapshot_set_value();
$self->zfs_destroy_snapshot("estimate");
}
sub command_pre_dle_backup {
my $self = shift;
- $self->zfs_snapshot_set_value("backup");
+ $self->zfs_snapshot_set_value();
if ($self->{error_status} == $Amanda::Script_App::GOOD) {
$self->zfs_create_snapshot("backup");
print "PROPERTY directory $self->{directory}\n";