List Info

Thread: Digest Number 1261




Digest Number 1261
country flaguser name
United States
2007-09-21 08:20:10

Messages In This Digest (2 Messages)

Messages

1a.

Re: Modifications to amdump

Posted by: "Marc Muehlfeld" Marc.Muehlfeldmedizinische-genetik.de?Subject= Re%3A%20Modifications%20to%20amdump"> Marc.Muehlfeldmedizinische-genetik.de

Thu Sep 20, 2007 1:33 pm (PST)

Hi,

I tried to find a better solution than my last one to improve errorhandling in
amdump.

I modified the script and now it writes the exit codes on failures together
with a human readable message to stdout (some parts are redirected to the
logfile). Also an eMail is send to the configured mailto address (just not,
when I can't read the config, then it's just stdout).

In the later part of the script, commands that fail (e. g. planner,
driver,...) all appearing errors are collected and mailed together in the end.
Also it's printed to stdout/logfile.

I build this new way on a new function "ExitHandler" inside the script.

I just tried this script on linux using bash. I hope I used no bash-only
conditions, so it is platform independent. But it would be nice if someone
could try this on different shells/platformsm, too.

Please let me know your suggestions, improvement suggestions, bugs,...

Regards
Marc

----------

#!/bin/sh
#
# Amanda, The Advanced Maryland Automatic Network Disk Archiver
# Copyright (c) 1991-1998 University of Maryland at College Park
# All Rights Reserved.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of U.M. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. U.M. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
# Author: Marc Muehlfeld, Germany
# http://marc-muehlfeld.de
#
#
# Based on the script amdump from James da Silva, Systems Design and Analysis Group
# Computer Science Department
# University of Maryland at College Park
#

#
# amdump: Manage running one night's Amanda dump run.
#

prefix=prefix
exec_prefix=exec_prefix
sbindir=sbindir
libexecdir=libexecdir
confdir=CONFIG_DIR

PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
export PATH

# Use version suffixes
USE_VERSION_SUFFIXES="USE_VERSION_SUFFIXES"
if test "$USE_VERSION_SUFFIXES" = "yes"; then
SUF="-VERSION"
else
SUF=
fi

# Check if no arguments were given.
# We exit here without email, because without config, we can't get the mailto.
if [ $# -lt 1 ] ; then
echo "Usage: amdump config [host [disk...]...]" 1>&2
exit 1
fi

# Check if the configuration directory exists
# We exit here without email, because without existing config, we can't get
# the mailto.
conf=$1
if [ ! -d $confdir/$conf ] ; then
echo "amdump$SUF: could not find directory $confdir/$conf" 1>&2
exit 1
fi
shift

# Check if mail programm is available
MAILER="MAILER"
if [ ! -x "$MAILER" ] ; then
echo "Mailprogram for reports and errors is missing or not executable." 1>&2
exit 1
else
# Get mailto address for current configuration or quit
MAILTO="`amgetconf$SUF $conf mailto`" 1>&2
if [ $? -ne 0 ] ; then
echo "Can't read amanda.conf. Exiting."
exit 1
fi
fi

# Function for exit handling.
# Usage: ExitHandler [YES|NO] [Error message text] [Exit code]
function ExitHandler () {

# Get variables
CONTINUE="$1"
ERRMSG="$2"
EXITCODE=$3

# On CONTINUE==NO we quit this script (with printing and mailing
# the error message)
if [ "$CONTINUE" == "NO" ] ; then
echo "$ERRMSG" 1>&2
echo "$ERRMSG" | $MAILER -s "ERROR KDD AMANDA REPORT FOR `date +%B" "%e", "%Y`" "$MAILTO"
exit $EXITCODE
fi

# On CONTINUE==YES we print the error (it could go to the log)
# and collect it for a cummulative error email.
if [ "$CONTINUE" == "YES" ] ; then
echo -e "$ERRMSG (Error code: $EXITCODE)" 1>&2
ERRMSG_ALL=";$ERRMSG_ALLn$ERRMSG (Error code: $EXITCODE)"
fi

# If no ERRMSG was given, then we are at the end of the script
if [ -z "$ERRMSG" ] ; then
if [ -z "$ERRMSG_ALL" ] ; then
# If we have no errors collected, just quit.
exit $EXITCODE
else
# If we have some errors, print and mail them,
# then quit.
echo -e "$ERRMSG_ALL" | $MAILER -s "ERROR KDD AMANDA REPORT FOR `date +%B" "%e", "%Y`" "$MAILTO"
exit $EXITCODE
fi
fi

}

# Go to configuration directory
cd $confdir/$conf || ExitHandler NO "Can't switch to configuration directory $conf." $?

# Get logdir out of config
logdir=`amgetconf$SUF $conf logdir "$"`
[ $? -ne 0 ] && ExitHandler NO "Can't get logdir from amanda.conf." $?

# Get tapecycle out of config
tapecycle=`amgetconf$SUF $conf tapecycle "$"`
[ $? -ne 0 ] && ExitHandler NO "Can't get tapecycle from amanda.conf." $?

# Get dumpuser out of config
dumpuser=`amgetconf$SUF $conf dumpuser "$"`
[ $? -ne 0 ] && ExitHandler NO "Can't get dumpuser from amanda.conf." $?

# Find out who am I
runuser=`{ whoami ; } 2>/dev/null`
if [ $? -ne 0 ] ; then
# If whoami failed, try it on a different way using id
idinfo=`{ id ; } 2>/dev/null`
if [ $? -ne 0 ] ; then
runuser=${LOGNAME:-"??unknown??"}
else
runuser=`echo $idinfo | sed -e 's/).*//' -e 's/^.*(//'`
fi
fi

# Check if the user who runs this script is the configured dumpuser
if [ $runuser != $dumpuser ]; then
ExitHandler NO "amdump: must be run as user $dumpuser, not $runuser" 1
fi

# If there's a hold-file wait until it's removed
if test -f hold ; then
echo "amdump: waiting for hold file to be removed" 1>&2
while test -f hold ; do
sleep 60
done
fi

# Set logfile variable
errfile=$logdir/amdump

# Check if amdump or amflush is currently running for the specified configuration
if [ -f $errfile ] || [ -f $logdir/log ] ; then
ExitHandler NO "amdump or amflush is already running, or you must run amcleanup" 1
fi

# Set umask to protect the files we write
umask 077

# Initialize exit_status
exit_status=0;

# Create logfile
touch $errfile
[ $? -ne 0 ] && ExitHandler YES "Can't create logfile." $?

# Write logfile
exec < /dev/null 2>>$errfile 1>&2
[ $? -ne 0 ] && ExitHandler YES "Can't write to logfile. Continue anyway.&quot; $?

# Send a header to the logfile
echo "amdump: start at `date`&quot;
echo "amdump: datestamp `date +%Y%m%d`&quot;
echo "amdump: starttime `date +%Y%m%d%H%M%S`"

# Start backup
$libexecdir/planner$SUF $conf "$" | $libexecdir/driver$SUF $conf "$"
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error running planner or driver.&quot; $exit_code

# Send a timestamp to the log after finish backup
echo "amdump: end at `date`&quot;

# Generate statistic for the run
$sbindir/amreport$SUF $conf "$"
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error running amreport.&quot; $exit_code

# Roll the log file to its datestamped name.
$libexecdir/amlogroll$SUF $conf "$"
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error running amlogroll." $exit_code

# Trim the log file to those for dumps that still exist.
$libexecdir/amtrmlog$SUF $conf "$"
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error running amtrmlog.&quot; $exit_code

# Trim the index file to those for dumps that still exist.
$libexecdir/amtrmidx$SUF $conf "$"
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error running amtrmidx.&quot; $exit_code

# Keep a debug log through the tapecycle plus a couple of days.
maxdays=`expr $tapecycle + 2`
days=1

# First, find out the last existing errfile,
# to avoid ``infinite'' loops if tapecycle is infinite
while [ $days -lt $maxdays ] && [ -f $errfile.$days ] ; do
days=`expr $days + 1`
done

# Now, renumber the existing log files
while [ $days -ge 2 ] ; do

ndays=`expr $days - 1`
mv $errfile.$ndays $errfile.$days

exit_code=$?
echo $exit_code
[ $exit_code -ne 0 ] && ExitHandler YES "Error renumbering logfiles.&quot; $exit_code

days=$ndays

done

# Rename logfile amdump to amdump.1
mv $errfile $errfile.1
exit_code=$?
[ $exit_code -ne 0 ] && ExitHandler YES "Error renaming logfile amdump to amdump.1.&quot; $exit_code

# Quit and return the a final exit status
ExitHandler "&quot; "&quot; 0

2.

It's a bird -- it's a plane -- no, it's the Device API!

Posted by: "Dustin J. Mitchell" dustinzmanda.com?Subject= Re%3AIt%27s%20a%20bird%20--%20it%27s%20a%20plane%20--%20no%2C%20it%27s%20the%20Device%20API%21"> dustinzmanda.com

Thu Sep 20, 2007 3:55 pm (PST)

I'm happy to announce that the Device API is going to come in for a
long and hopefully smooth landing over the next week or so. The merge
will take the form of a significant number (100-200) of commits of
varying sizes representing merges from the internal Zmanda tree.

There are a few details left to be worked out -- among them,
amfetchdump's inventory (-i) mode isn't quite right, and amverify
doesn't play well with vtapes. We've decided to go ahead with the
merge anyway, because the tree divergence is getting out of hand, and
because these problems will actually be *easier* to fix after the
merge is complete. With the promise that we'll fix these problems and
all others that crop up before the next release, we hope you'll
forgive the indiscretion.

The whole process has a few consequences for you, the l33t Amanda hacker:

- During the merge, the tree will be unstable and possibly broken.
Most breakage will get shaken out by subsequent merges, often within
an hour or two. Even so, the upshot is that if you're running your
production backups off the nightly builds, you'll want to pause that
process for a while.

- After the merge, we'll be putting in some long hours testing the
result, and will enlist the help of the platform experts and anyone
else who's available, too.

- This merge contains some radical changes (among them: the addition
of glib2 as a dependency) which were discussed and roughly agreed upon
quite some time ago. I'm glad to have discussion of these changes as
they get merged, but please be sure to check out the archives first,
so we don't needlessly repeat the previous conversation.

- The biggest assistance we can use immediately is documentation for
installing Amanda on your platform, including the new glib2
requirement. Once I have the tree in a place where that requirement
is in place, I'll produce a tarball to "practice" on, and start a new
thread on the list.

Wish me luck crunching all these changsets. It's going to be a long week.

Dustin

P.S. To put credit where credit is due, most of the changes I'm
merging were Ian's work, not mine.

--
Storage Software Engineer
http://www.zmanda.com

Recent Activity
Visit Your Group
Sitebuilder

Build a web site

quickly & easily

with Sitebuilder.

Fitness Zone

on Yahoo! Groups

Find Groups all

about healthy living.

Real Food Group

Share recipes

and favorite meals

w/ Real Food lovers.

Need to Reply?

Click one of the "Reply" links to respond to a specific message in the Daily Digest.

Create New Topic | Visit Your Group on the Web
Yahoo! Groups
Change settings via the Web (Yahoo! ID required)
Change settings via email: amanda-hackers-normal@yahoogroups.com?subject=Email Delivery: Indiviual Email">Switch delivery to Individual | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | amanda-hackers-unsubscribe@yahoogroups.com?subject=Unsubscribe"> Unsubscribe
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )