: !/bin/sh . /u/catcom/catcom_vars NODENAME=`uname -n` logfile="/u/catcom/wb/$0.log" rm -f "$logfile" # all output to logfile exec >>"$logfile" 2>&1 #------------------------------------ busrcdir="$1" findopts="$2" busshdest="$3" buid="$4" #targetfolder="/s02/ecut21" targetfolder="/s01/ecut21" budtag=`date "+%Y%m%d"` #outfile="/s04/ecut21/${buid}_${budtag}.cpio.gz" #outfile="/s04/ecut21/${buid}.cpio.gz" #outfile="/s03/ecut21/${buid}.cpio.gz" outfile="${targetfolder}/${buid}.cpio.gz" #--------- echo "$0: Started Telmax21 $busrcdir backup (entire system)" `date` echo " buid=[$buid]" echo " busrcdir=[$busrcdir] findopts=[$findopts]" echo " busshdest=[$busshdest]" echo " outfile = $outfile" echo "" PATH="$PATH:/usr/local/bin" export PATH # backup this folder down cd "$1" echo "target folder BEFORE backup ${targetfolder}:" # also tests ssh connection ssh -n "$busshdest" "ls -altr $targetfolder" echo "" time 2>>"$logfile" find . "$findopts" -depth -print | \ cpio -ocv 2>>"$logfile" | \ gzip -9 -c | \ ssh 2>>"$logfile" "$busshdest" "dd of=$outfile" echo "" echo "target folder AFTER backup ${targetfolder}:" ssh -n "$busshdest" "ls -altr $targetfolder" echo "" #------------------------------------------ #tail $0.log #echo "" #echo "$0: Finished " echo "" echo "$0: Finished $busrcdir" `date` # email notification BACKUPEMAILLISTFILE="$CATDB/backup.emaillist" if [ -f "$BACKUPEMAILLISTFILE" ]; then emaillist=`cat $BACKUPEMAILLISTFILE` else emaillist="root" fi ## Testing emaillist="support@transmit.com.au" if [ -n "$emaillist" ]; then # Force mail to pass DATE as GMT TZ=''; export TZ subject="${NODENAME}: Telmax21 Backup Status" ematt_bulktextfile="/tmp/$0.$$.bt.tmp" export ematt_bulktextfile ( head -50 "$logfile" echo "" echo " - " echo " - snip - snip - snip -" echo " - " echo "" tail -50 "$logfile" ) > "$ematt_bulktextfile" ## zip the logfile #rm -f "${logfile}.zip" #zip -9 "${logfile}.zip" "$logfile" cat "$ematt_bulktextfile" | mail -s "$subject" $emaillist #ematt "${logfile}.zip" "$subject" $emaillist rm -f "$ematt_bulktextfile" #rm -f "${logfile}.zip} else # output to stanadrd out cat "$logfile" fi exit 0