Amanda-Users

Re: Howto for post/pre-backup-commands

2003-08-19 06:20:02
Subject: Re: Howto for post/pre-backup-commands
From: Simon Frettloeh <sifr AT aifb.uni-karlsruhe DOT de>
To: Amanda User Mailingliste <amanda-users AT amanda DOT org>
Date: Tue, 19 Aug 2003 12:17:14 +0200 (CEST)
Since I've been searching long for a solution, I'll try to present a 
little Mini-HOWTO for this problem. I hope it's correct, but if not, 
maybe some Amanda Cracks ;-) could correct me.

On Sun, 17 Aug 2003, Simon Frettloeh wrote:

> Does anybody of you has experience "using" the dumper-API to perform
> this task? In the document nothing further to this is said. Does
> somewhere a HOWTO for this issue exist?

Using the dumper-API seems not to work.


But there's another solution for this problem:

You have to compile amanda with a modification of the option
"--with-gnutar=/bin/tar". If you change this to perhaps
"--with-gnutar=/bin/myowntar", you gain several possibilities:

a) you can write a shell script "myowntar" which can execute 
   pre-/post-backup commands:
   ===snip====================
   REALTAR=/bin/tar
   exec yourprebackupcommand
   exec $REALTAR "$@"
   exec yourpostbackupcommand
   ===snap====================
   For a more complex but also more flexible script look at the end of my 
   mail. I hope this one's correct. I'm not so good in shell programming,
   but I think, you have to supress all messages from your own commands,
   so that Amanda doesn't get confused. 

b) you can create a symbolic link "myowntar --> tar". So amanda 
   still works and you have the possibility of introducing a script
   later on. 

c) you can create a copy "myowntar" of tar and have the same 
   possibilities like b).


Here a very good solution for a shell script, which I got mailed:
Please take care using this script. You've got to be beware, that backups 
could fail, if you make mistakes here. If you don't like logging the 
action of this script, just comment the marked lines.
===snip=================================================================
# create logfiles to spectate what your own tar does
LOG=/tmp/amanda/myowntar.debug 
date >> $LOG 
echo "$@" >> $LOG 

if [ "$3" = "/dev/null" ] 
  then echo "Estimate only" >> $LOG 
  else echo "Real backup" >> $LOG 
fi 
 
# with these conditions you've got the possibility
# to perform different, specific commands on the different
# dumps you're running
if [ "$3" = "-"  -a  "$5" = "/etc" ] 
then 
     # logfile action
     echo "/etc: want to execute some progs first">>$LOG 
     
     # here you can place your PRE-backup commands
     myprebackupcommand >&2
 
     /bin/tar "$@" 
 
     # logfile action
     echo "Finished the real backup; some postprocessing">>$LOG 

     # here you can place your POST-backup commands
     mypostbackupcommand >&2

else 
     /bin/tar "$@" 
fi 
===snap============================================================
No garantuee for the correctness of this script! You still have to 
adapt it to your own system!


Have fun with it and be careful. Don't mess up your backup system!

Ciao,
Simon Frettloeh


<Prev in Thread] Current Thread [Next in Thread>