3 # Amanda, The Advanced Maryland Automatic Network Disk Archiver
4 # Copyright (c) 1991-1998 University of Maryland at College Park
7 # Permission to use, copy, modify, distribute, and sell this software and its
8 # documentation for any purpose is hereby granted without fee, provided that
9 # the above copyright notice appear in all copies and that both that
10 # copyright notice and this permission notice appear in supporting
11 # documentation, and that the name of U.M. not be used in advertising or
12 # publicity pertaining to distribution of the software without specific,
13 # written prior permission. U.M. makes no representations about the
14 # suitability of this software for any purpose. It is provided "as is"
15 # without express or implied warranty.
17 # U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 # Author: James da Silva, Systems Design and Analysis Group
25 # Computer Science Department
26 # University of Maryland at College Park
30 # amdump: Manage running one night's Amanda dump run.
34 exec_prefix=@exec_prefix@
36 libexecdir=@libexecdir@
40 PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
43 USE_VERSION_SUFFIXES="@USE_VERSION_SUFFIXES@"
44 if test "$USE_VERSION_SUFFIXES" = "yes"; then
51 if [ ! -d $confdir/$conf ]; then
52 echo "amdump$SUF: could not find directory $confdir/$conf"
56 cd $confdir/$conf || exit 1
58 logdir=`amgetconf$SUF $conf logdir`
59 [ $? -ne 0 ] && exit 1
60 errfile=$logdir/amdump
61 tapecycle=`amgetconf$SUF $conf tapecycle`
62 [ $? -ne 0 ] && exit 1
63 dumpuser=`amgetconf$SUF $conf dumpuser`
64 [ $? -ne 0 ] && exit 1
66 runuser=`{ whoami ; } 2>/dev/null`
68 idinfo=`{ id ; } 2>/dev/null`
70 runuser=${LOGNAME:-"??unknown??"}
72 runuser=`echo $idinfo | sed -e 's/).*//' -e 's/^.*(//'`
76 if [ $runuser != $dumpuser ]; then
77 echo "amdump: must be run as user $dumpuser, not $runuser"
82 echo "amdump: waiting for hold file to be removed" >&2
83 while test -f hold; do
88 if test -f $errfile || test -f $logdir/log; then
89 echo "amdump: amdump or amflush is already running, or you must run amcleanup" >&2
95 # Plan and drive the dumps.
96 #exec </dev/null >$errfile 2>&1
98 exec </dev/null 2>>$errfile 1>&2
99 echo "amdump: start at `date`"
100 echo "amdump: datestamp `date +%Y%m%d`"
101 $libexecdir/planner$SUF "$@" | $libexecdir/driver$SUF $conf
102 echo "amdump: end at `date`"
104 # Send out a report on the dumps.
105 $sbindir/amreport$SUF $conf
107 # Roll the log file to its datestamped name.
108 $libexecdir/amlogroll$SUF $conf
110 # Trim the log file to those for dumps that still exist.
111 $libexecdir/amtrmlog$SUF $conf
113 # Trim the index file to those for dumps that still exist.
114 $libexecdir/amtrmidx$SUF $conf
116 # Keep a debug log through the tapecycle plus a couple of days.
117 maxdays=`expr $tapecycle + 2`
119 # First, find out the last existing errfile,
120 # to avoid ``infinite'' loops if tapecycle is infinite
121 while [ $days -lt $maxdays ] && [ -f $errfile.$days ]; do
122 days=`expr $days + 1`
124 # Now, renumber the existing log files
125 while [ $days -ge 2 ]; do
126 ndays=`expr $days - 1`
127 mv $errfile.$ndays $errfile.$days
130 mv $errfile $errfile.1