Re: pre/post scripting

2014-07-09 Thread Stefan G. Weichinger
Am 09.07.2014 16:17, schrieb Stefan G. Weichinger:
 
 Would anyone mind sharing some real world scripts he uses with amanda?
 
 I think of stopping/starting DBs or something like that.
 
 I would appreciate some good templates ;-)

I started playing with the email examples from the docs but they fail
straight away:


define script-tool sc-email {
comment email me before this DLE is backed up
plugin  script-email
execute-on pre-dle-backup
execute-where server
property mailto l...@xunil.at
}



... gives me

Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
in concatenation (.) or string at
/usr/libexec/amanda/application/script-email line 181.
Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
$args[2] in join or string at
/usr/libexec/amanda/application/script-email line 182.
Jul 09 16:37:11 amanda Script_email[20664]: Use of uninitialized value
$args[2] in open at /usr/libexec/amanda/application/script-email line 185.
Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
in concatenation (.) or string at
/usr/libexec/amanda/application/script-email line 186.


Does that work for anyone else?
Does it need anymore properties set?

Thanks, Stefan




Re: pre/post scripting

2014-07-09 Thread Gene Heskett
On Wednesday 09 July 2014 10:17:03 Stefan G. Weichinger did opine
And Gene did reply:
 Would anyone mind sharing some real world scripts he uses with amanda?
 
 I think of stopping/starting DBs or something like that.
 
 I would appreciate some good templates ;-)
 
 Thanks, Stefan

I've been using GenesAmandaHelper-0.61 (on my web page, see sig) for 
several years, but it doesn't address those points.  Its an amanda wrapper 
in a bash script. What it does, is facilitate a bare metal recovery to the 
exact state of the last backup, by appending a copy of amanda's database 
stuff and configuration directories to the end of the current backup after 
amanda is finished, or as separate files if using vtapes on a separate 
hard drive like I've been doing for years. One could even add to it, the 
amanda home dir where I build it for the install, so that the complete 
amanda src/install tree is available.  I just never got around to doing 
that.

Cheers, Gene Heskett
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
Genes Web page http://geneslinuxbox.net:6309/gene
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS


Re: pre/post scripting

2014-07-09 Thread John Hein
Stefan G. Weichinger sgw-at-amanda.org |amusersj-ml0| wrote at 16:38 +0200 on 
Jul  9, 2014:
  Am 09.07.2014 16:17, schrieb Stefan G. Weichinger:
  
   Would anyone mind sharing some real world scripts he uses with amanda?
  
   I think of stopping/starting DBs or something like that.
  
   I would appreciate some good templates ;-)
 
  I started playing with the email examples from the docs but they fail
  straight away:
 
 
  define script-tool sc-email {
  comment email me before this DLE is backed up
  plugin  script-email
  execute-on pre-dle-backup
  execute-where server
  property mailto l...@xunil.at
  }
 
 
 
   gives me
 
  Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
  in concatenation (.) or string at
  /usr/libexec/amanda/application/script-email line 181.
  Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
  $args[2] in join or string at
  /usr/libexec/amanda/application/script-email line 182.
  Jul 09 16:37:11 amanda Script_email[20664]: Use of uninitialized value
  $args[2] in open at /usr/libexec/amanda/application/script-email line 185.
  Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
  in concatenation (.) or string at
  /usr/libexec/amanda/application/script-email line 186.
 
 
  Does that work for anyone else?
  Does it need anymore properties set?
 
  Thanks, Stefan

I'm not sure about the exact cause of the errors you're seeing, but it
looks like the mailto check will not accept '@' or '.' (or dashes or
underscores or numbers).

To address that, maybe try this patch:

--- libexec/amanda/application/script-email.orig   2009-11-06 
10:27:46.0 -0700
+++ libexec/amanda/application/script-email2014-07-09 
10:02:06.0 -0600
@@ -154,7 +154,7 @@
my $dest;
if ($self-{mailto}) {
   my $destcheck = join ',', @{$self-{mailto}};
-  $destcheck =~ /^([a-zA-Z,]*)$/;
+  $destcheck =~ /^([-_[:alnum:],@.]*)$/;
   $dest = $1;
} else {
   $dest = root;


Or don't try to do the mailer's job and just skip the whole destcheck
part - let the mailer catch any errors:


--- libexec/amanda/application/script-email.orig   2009-11-06 
10:27:46.0 -0700
+++ libexec/amanda/application/script-email2014-07-09 
11:02:18.0 -0600
@@ -153,9 +153,7 @@
my($function) = @_;
my $dest;
if ($self-{mailto}) {
-  my $destcheck = join ',', @{$self-{mailto}};
-  $destcheck =~ /^([a-zA-Z,]*)$/;
-  $dest = $1;
+  $dest = join ',', @{$self-{mailto}};
} else {
   $dest = root;
}


Re: pre/post scripting

2014-07-09 Thread Stefan G. Weichinger
Am 09.07.2014 17:13, schrieb Gene Heskett:
 On Wednesday 09 July 2014 10:17:03 Stefan G. Weichinger did opine
 And Gene did reply:
 Would anyone mind sharing some real world scripts he uses with amanda?

 I think of stopping/starting DBs or something like that.

 I would appreciate some good templates ;-)

 Thanks, Stefan
 
 I've been using GenesAmandaHelper-0.61 (on my web page, see sig) for 
 several years, but it doesn't address those points.  Its an amanda wrapper 
 in a bash script. What it does, is facilitate a bare metal recovery to the 
 exact state of the last backup, by appending a copy of amanda's database 
 stuff and configuration directories to the end of the current backup after 
 amanda is finished, or as separate files if using vtapes on a separate 
 hard drive like I've been doing for years. One could even add to it, the 
 amanda home dir where I build it for the install, so that the complete 
 amanda src/install tree is available.  I just never got around to doing 
 that.

Not what I asked for, you know. I want to get rid of some
wrapper-constructions by using the amanda script API ...

Aside from that, feel free to post the exact URL pointing to your
script, I wasn't able to spot it on your site right now (not mentioned
on the top page). Maybe someone wants to have a look and somehow adapt
it to use with the script api.

Stefan



Re: pre/post scripting

2014-07-09 Thread Stefan G. Weichinger
Am 09.07.2014 19:06, schrieb John Hein:

 I'm not sure about the exact cause of the errors you're seeing, but it
 looks like the mailto check will not accept '@' or '.' (or dashes or
 underscores or numbers).
 
 To address that, maybe try this patch:
 
 --- libexec/amanda/application/script-email.orig   2009-11-06 
 10:27:46.0 -0700
 +++ libexec/amanda/application/script-email2014-07-09 
 10:02:06.0 -0600
 @@ -154,7 +154,7 @@
 my $dest;
 if ($self-{mailto}) {
my $destcheck = join ',', @{$self-{mailto}};
 -  $destcheck =~ /^([a-zA-Z,]*)$/;
 +  $destcheck =~ /^([-_[:alnum:],@.]*)$/;
$dest = $1;
 } else {
$dest = root;
 
 
 Or don't try to do the mailer's job and just skip the whole destcheck
 part - let the mailer catch any errors:
 
 
 --- libexec/amanda/application/script-email.orig   2009-11-06 
 10:27:46.0 -0700
 +++ libexec/amanda/application/script-email2014-07-09 
 11:02:18.0 -0600
 @@ -153,9 +153,7 @@
 my($function) = @_;
 my $dest;
 if ($self-{mailto}) {
 -  my $destcheck = join ',', @{$self-{mailto}};
 -  $destcheck =~ /^([a-zA-Z,]*)$/;
 -  $dest = $1;
 +  $dest = join ',', @{$self-{mailto}};
 } else {
$dest = root;
 }
 


Thanks, John ... I just tried your 2nd patch and the email gets through now.

I was maybe too demanding to assume that an email-address might contain
@ or . :-P

Thanks again, I will continue to find my way with scripting,
Stefan


Re: pre/post scripting

2014-07-09 Thread Stefan G. Weichinger
Am 09.07.2014 16:17, schrieb Stefan G. Weichinger:
 
 Would anyone mind sharing some real world scripts he uses with amanda?
 
 I think of stopping/starting DBs or something like that.

When I think about this I assume that some sudo-trickery might be
needed, right?

The amanda-user won't be allowed to stop/start mysql, for example, so I
think I this will need using sudo or maybe adding the amanda-user to
some group with the needed permissions.

How do you solve this?

I will do some tests tomorrow and have a look.

Stefan



Re: pre/post scripting

2014-07-09 Thread Schlacta, Christ
Or you could, you know, add Amanda to the sudoers.d folder
On Jul 9, 2014 11:21 AM, Stefan G. Weichinger s...@amanda.org wrote:

 Am 09.07.2014 16:17, schrieb Stefan G. Weichinger:
 
  Would anyone mind sharing some real world scripts he uses with amanda?
 
  I think of stopping/starting DBs or something like that.

 When I think about this I assume that some sudo-trickery might be
 needed, right?

 The amanda-user won't be allowed to stop/start mysql, for example, so I
 think I this will need using sudo or maybe adding the amanda-user to
 some group with the needed permissions.

 How do you solve this?

 I will do some tests tomorrow and have a look.

 Stefan




Re: pre/post scripting

2014-07-09 Thread Stefan G. Weichinger
Am 09.07.2014 20:27, schrieb Schlacta, Christ:
 Or you could, you know, add Amanda to the sudoers.d folder

Sure, that's what I thought of.



Re: pre/post scripting

2014-07-09 Thread Gene Heskett
On Wednesday 09 July 2014 14:12:23 Stefan G. Weichinger did opine
And Gene did reply:
 Am 09.07.2014 17:13, schrieb Gene Heskett:
  On Wednesday 09 July 2014 10:17:03 Stefan G. Weichinger did opine
  
  And Gene did reply:
  Would anyone mind sharing some real world scripts he uses with
  amanda?
  
  I think of stopping/starting DBs or something like that.
  
  I would appreciate some good templates ;-)
  
  Thanks, Stefan
  
  I've been using GenesAmandaHelper-0.61 (on my web page, see sig) for
  several years, but it doesn't address those points.  Its an amanda
  wrapper in a bash script. What it does, is facilitate a bare metal
  recovery to the exact state of the last backup, by appending a copy
  of amanda's database stuff and configuration directories to the end
  of the current backup after amanda is finished, or as separate files
  if using vtapes on a separate hard drive like I've been doing for
  years. One could even add to it, the amanda home dir where I build
  it for the install, so that the complete amanda src/install tree is
  available.  I just never got around to doing that.
 
 Not what I asked for, you know. I want to get rid of some
 wrapper-constructions by using the amanda script API ...
 
This MUST be a wrapper, as it has things to do that cannot be done until 
after amanda has finished.

 Aside from that, feel free to post the exact URL pointing to your
 script, I wasn't able to spot it on your site right now (not mentioned
 on the top page). Maybe someone wants to have a look and somehow adapt
 it to use with the script api.

I thought I had put it in Genes-os9-stf, sort of a catchall, but on 
looking, I hadn't.  Sorry I wasted your time.

And I probably won't given the attitude of the other person who looked at 
it  complained that it was not system agnostic but needed configured.  
All I can say is that it works very well for me, giving me the ability to 
restore a newly formatted drive to last nights backup state if I have to. 
But I haven't had to, modern drives seem to give enough warning of 
impending failure that I haven't had to.

 Stefan


Cheers, Gene Heskett
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
Genes Web page http://geneslinuxbox.net:6309/gene
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS


Re: pre/post scripting

2014-07-09 Thread Jean-Louis Martineau

John,

Thanks for debugging it.
You are right, we should accept all characters for an email address.

I committed the attached patch.
It set $dest and untaint it.
It execute the mailer without using a shell.

Jean-Louis

On 07/09/2014 01:06 PM, John Hein wrote:

Stefan G. Weichinger sgw-at-amanda.org |amusersj-ml0| wrote at 16:38 +0200 on 
Jul  9, 2014:
   Am 09.07.2014 16:17, schrieb Stefan G. Weichinger:
   
Would anyone mind sharing some real world scripts he uses with amanda?
   
I think of stopping/starting DBs or something like that.
   
I would appreciate some good templates ;-)
  
   I started playing with the email examples from the docs but they fail
   straight away:
  
  
   define script-tool sc-email {
   comment email me before this DLE is backed up
   plugin  script-email
   execute-on pre-dle-backup
   execute-where server
   property mailto l...@xunil.at
   }
  
  
  
    gives me
  
   Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
   in concatenation (.) or string at
   /usr/libexec/amanda/application/script-email line 181.
   Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
   $args[2] in join or string at
   /usr/libexec/amanda/application/script-email line 182.
   Jul 09 16:37:11 amanda Script_email[20664]: Use of uninitialized value
   $args[2] in open at /usr/libexec/amanda/application/script-email line 185.
   Jul 09 16:37:11 amanda Script_email[20663]: Use of uninitialized value
   in concatenation (.) or string at
   /usr/libexec/amanda/application/script-email line 186.
  
  
   Does that work for anyone else?
   Does it need anymore properties set?
  
   Thanks, Stefan

I'm not sure about the exact cause of the errors you're seeing, but it
looks like the mailto check will not accept '@' or '.' (or dashes or
underscores or numbers).

To address that, maybe try this patch:

--- libexec/amanda/application/script-email.orig   2009-11-06 
10:27:46.0 -0700
+++ libexec/amanda/application/script-email2014-07-09 
10:02:06.0 -0600
@@ -154,7 +154,7 @@
 my $dest;
 if ($self-{mailto}) {
my $destcheck = join ',', @{$self-{mailto}};
-  $destcheck =~ /^([a-zA-Z,]*)$/;
+  $destcheck =~ /^([-_[:alnum:],@.]*)$/;
$dest = $1;
 } else {
$dest = root;


Or don't try to do the mailer's job and just skip the whole destcheck
part - let the mailer catch any errors:


--- libexec/amanda/application/script-email.orig   2009-11-06 
10:27:46.0 -0700
+++ libexec/amanda/application/script-email2014-07-09 
11:02:18.0 -0600
@@ -153,9 +153,7 @@
 my($function) = @_;
 my $dest;
 if ($self-{mailto}) {
-  my $destcheck = join ',', @{$self-{mailto}};
-  $destcheck =~ /^([a-zA-Z,]*)$/;
-  $dest = $1;
+  $dest = join ',', @{$self-{mailto}};
 } else {
$dest = root;
 }


diff --git a/application-src/script-email.pl b/application-src/script-email.pl
index 2cb5e8e..0e86e77 100644
--- a/application-src/script-email.pl
+++ b/application-src/script-email.pl
@@ -173,16 +173,18 @@ sub sendmail {
my $dest;
if ($self-{mailto}) {
   my $destcheck = join ',', @{$self-{mailto}};
-  $destcheck =~ /^([a-zA-Z,]*)$/;
+  $destcheck =~ /^(.*)$/;
   $dest = $1;
} else {
   $dest = root;
}
+
+   my $subject =  $self-{config} $function $self-{host} $self-{disk} $self-{device}  . join ( , @{$self-{level}});
my @args = ( -s, $self-{config} $function $self-{host} $self-{disk} $self-{device}  . join ( , @{$self-{level}}), $dest );
my $args = join( , @args);
-   debug(cmd: $Amanda::Constants::MAILER $args\n);
+   debug(cmd: $Amanda::Constants::MAILER -s \$subject\  . $dest);
my $mail;
-   open $mail, '|-', $Amanda::Constants::MAILER, @args;
+   open $mail, '|-', $Amanda::Constants::MAILER, '-s', $subject, $dest;
print $mail $self-{action} $self-{config} $function $self-{host} $self-{disk} $self-{device} , join ( , @{$self-{level}}), \n;
close $mail;
 }


Re: pre/post scripting

2014-07-09 Thread Gene Heskett
On Wednesday 09 July 2014 18:11:17 Jon LaBadie did opine
And Gene did reply:
 On Wed, Jul 09, 2014 at 03:46:14PM -0400, Gene Heskett wrote:
 ...
 
   Not what I asked for, you know. I want to get rid of some
   wrapper-constructions by using the amanda script API ...
  
  This MUST be a wrapper, as it has things to do that cannot be done
  until after amanda has finished.
 
 Top of the head blueskying, could your activites be the LAST thing
 amanda does?   I.e. after all dumps and tapings and reports?
 
 If it must be done when amanda is no longer running, another
 possibility.  Maybe could the script api be used to issue an
 at command.  Something like at 'now + 5 minutes' your_script.
 Of course the 5 minutes would have to be determined.
 
 Jon

Thats a bit complex IMO.  It takes care of launching amanda, and when 
amanda has returned, finished, it then does the rest of its thing, saving 
the database amanda generates in /usr/local/var, and the 
/usr/local/etc/amanda configuration that generated the backup.

Cheers, Gene Heskett
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
Genes Web page http://geneslinuxbox.net:6309/gene
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS