X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=application-src%2Famzfs-snapshot.pl;fp=application-src%2Famzfs-snapshot.pl;h=676e60e57b4ad9858cb95dad4db7d1f49153aead;hb=538ae376635af705ebcd686f3b4b7b72a6652985;hp=fefd25afb6543e3240384e15b3f986f6df794cea;hpb=11425c69eb58b6103beb68adc13912735ba36975;p=debian%2Famanda diff --git a/application-src/amzfs-snapshot.pl b/application-src/amzfs-snapshot.pl index fefd25a..676e60e 100644 --- a/application-src/amzfs-snapshot.pl +++ b/application-src/amzfs-snapshot.pl @@ -1,5 +1,5 @@ #!@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 @@ -14,7 +14,7 @@ # 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: @@ -26,6 +26,7 @@ # use lib '@amperldir@'; use strict; +use warnings; use Getopt::Long; package Amanda::Script::Amzfs_snapshot; @@ -41,13 +42,21 @@ use Amanda::Constants; 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; @@ -64,12 +73,15 @@ sub new { 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); } } @@ -90,15 +102,19 @@ sub command_support { 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"; } @@ -107,14 +123,19 @@ sub command_pre_dle_amcheck { 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"; @@ -124,14 +145,14 @@ sub command_pre_dle_estimate { 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";