#!/bin/ksh # syntax: ufsbackup [ -checkmath | -debug ] # # assumptions: # $tra_d - inherited from environment debug=false # list the database points (form: "u" with digits, ...) into a variable dbmounts="`lstdbmountpoints`" # determine day of week dayofweek=`date +%a` daynumber=`date +%w` # 0=Sunday, 1=Monday, ... 6=Saturday epochsecs=`date +%s` # WARNING: may not work in some version of date(1) (( cst_secs = $epochsecs - ( 6 * 3600 ) )) # shift epochsecs to CST (no DST) (( cst_days = $cst_secs / 86400 )) # near 11000 (( cst_week = ( $cst_days - 1 ) / 7 )) # Fri is weekstart, adjust +- to fix (( weeklytape = ( ( $cst_week + 0 ) % 6 ) + 1 )) # outputs 1 to 6 # ^adjust shift weeks case "$1" in -checkmath) set | egrep 'epoch|cst|week' | sort | uniq exit 0 ;; -debug) debug=true ;; esac # determine dumptype - daily (Mon - Thu), weekly (Fri, Sat, Sun), and setname dumptype= setname= case $dayofweek in Mon|Tue|Wed|Thu) dumptype=daily setname=$daynumber # will be 1, 2, 3, 4 echo '[selecting daily dump]' ;; Fri|Sat|Sun) dumptype=weekly setname="w"$weeklytape # w1 to w6 (don't need the double-quotes) echo '[selecting weekly dump]' ;; *) { echo 'ERROR: weekday name of $dayofweek invalid, aborting.' echo '(was the LANG variable set to other than english?)' } 1>&2 # redirect the stdout from the echo's to the stderr stream exit 2 ;; esac # determine the reel's identifier for mounting by operator # first char of hostname, uppercase (likely either "voyager" or "enterprise" host=`uname -n` # host1c=`echo $host | tr a-z A-Z | cut -c1` # Bourne shell method typeset -u -L1 host1c ; host1c=$host # Korn shell method reel="${host1c}${setname}" # give reel to operator if $debug ; then echo NOTE: in debugging mode, the command being omitted is: echo $tra_d/attach $reel $tapdev else # if not debugging, then do the real thing. if $tra_d/attach $reel $tapdev ; then echo tape $reel has been reported as successfully mounted else echo mount tape $reel failed, aborting 1>&2 exit 1 fi fi # generate the mount points to dump, excluding those from dbmounts for dailies # read thru the /etc/vfstab file and gather only the valid slice/mount points # to dump. For each one, create a dmp_pnt (name of the mount point) entry # totslices=0 cat /etc/vfstab | while read device rawdev mntpnt __toss ; do case $rawdev in /dev/rdsk/*|/dev/md/rdsk/*) # either /dev/rdsk/ or /dev/md/rdks/ # question: do we want to include it? include_it=false # assume false for starters case $dumptype in weekly) include_it=true # we do all of them on weeklies ;; daily) # include if it isn't listed in dbmounts search_token=${mntpnt#/} # delete the initial slash # see if the mount point is NOT in the excludes (dbmounts) if echo $dbmounts \ | grep -s -v '\<'$search_token'\>' >/dev/null then include_it=true fi ;; esac if $include_it ; then dmp_slice[$totslices]=$rawdev if [ "_$mntpnt" = "_/" ] ; then mntpnt=root fi dmp_pnt[$totslices]=${mntpnt#/} (( totslices = totslices + 1 )) fi ;; esac done if $debug ; then echo 'NOTE: debugging, dumping all lowercase variables to stdout...' set | grep '^[a-z]' | sort fi echo 'script not yet fully written, aborting' ; exit 1 exit 0 #-------------------------------------------------------------eof