#!/bin/sh # backup.net, called by crontab -e daily ethernet backup. Julian Stacey exit # remove when OK for jhs & mk local_host=`hostname -s` owner=`whoami` case $local_host in flip|lapd) local_original=/usr/home/$owner ( cd $local_original ; rdist back `hostname -s` ) 2>/dev/null # /usr/home/jhs is a directory on all hosts. # /home/mk --> /site/home/mk on most hosts exit ;; 'skyr') local_original=/usr/home/$owner remote_host=desk remote_duplicate=/usr2/data/backup.net/$owner local_tmp_dir=/usr/tmp ;; *) echo "$0: Don't know what to do for host name $local_host." exit 1 ;; esac # Any hosts that support rdist should have done an exit by now, # however, for hosts that do not support rdist, I now use rcp of tar images. # (note rcp converts sym links to directories, hence tar images are copied, # rather than invoking rcp direct on the trees ). shell_name=`basename $0` log_file=.$shell_name.log day=`date +%Y_%m_%d` tmp_file=$local_tmp_dir/.$shell_name.$owner.tmp todays_log=$local_tmp_dir/$shell_name.$owner.log cumulative_log=$local_original/$log_file chat="Started $shell_name $day { `date`" echo "$chat" > $todays_log echo "" >> $cumulative_log ; echo "$chat" >> $cumulative_log pwd=`pwd` cd $local_original collection=$shell_name.$day.tar.gz local_collection=$local_tmp_dir/$collection nice tar zcf $local_collection . ; \ nice rcp -p $local_collection \ $remote_host:$remote_duplicate/$collection \ | /bin/sh 2>&1 | cat> $tmp_file rm $local_collection cd $pwd cat $tmp_file >> $todays_log ; cat $tmp_file >> $cumulative_log if [ $local_original_2.x != .x ] then pwd=`pwd` cd $local_original_2 nice tar zcf $local_collection . ; nice rcp -p $local_collection \ $remote_host:$remote_duplicate_2/$collection \ | /bin/sh 2>&1 | cat >> $tmp_file rm $local_collection cd $pwd fi rm $local_tmp_dir/$shell_name.$day.tar.gz cat $tmp_file >> $todays_log cat $tmp_file >> $cumulative_log chat="Finished } Network Backup `date`" echo "$chat" >> $cumulative_log echo "$chat" >> $todays_log mail -s "cron: `hostname` backup.net: Net Backup $0" $owner < $todays_log rm $tmp_file $todays_log