⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autocptapes.in

📁 一套客户/服务器模式的备份系统代码,跨平台,支持linux,AIX, IRIX, FreeBSD, Digital Unix (OSF1), Solaris and HP-UX.
💻 IN
字号:
#!/bin/csh################### Start of $RCSfile: autocptapes.in,v $ #################### $Source: /home/alb/afbackup/afbackup-3.3.8.1/RCS/autocptapes.in,v $# $Id: autocptapes.in,v 1.3 2004/07/08 20:34:42 alb Exp alb $# $Date: 2004/07/08 20:34:42 $# $Author: alb $######### description ########################################################################################################################## User settable section ##### The backup server where to copy to, and the port number##set TARGETSERVER=localhost#set TARGETPORT=2989#set TARGETKEYFILE=""## The offset to get the target cartridge numbers from the source numbers##set CARTNUMOFFSET=0### End of user settable section ###onintr cleanupif (`echo "$*"|egrep '^ *-[khpo] *[^ ]+( +-[khpo] *[^ ]+)* *$'|wc -l` < 1) then  goto usageendifset args=`getopt h:k:o:p: "$*"`@ n=$#args / 2@ r=$#args - ( $n * 2 )if ($r != 1) goto usage@ n=$#args - 1set i=1while ($i <= $n)  set opt="$argv[$i]"  @ i++  set arg="$argv[$i]"  @ i++  switch (_"$opt")    case _-k:	set TARGETKEYFILE="$arg"	breaksw;    case _-h:	set TARGETSERVER="$arg"	breaksw;    case _-p:	set TARGETPORT="$arg"	breaksw;    case _-o:	set CARTNUMOFFSET="$arg"	breaksw;    default:	goto usage  endswendif (! $?BACKUP_HOME) then  set p=$0  set pnam=$p  set pnam=$pnam:t  if ($pnam == $0) then    foreach dir ($path)      if (-x $dir/$pnam) then	set p=$dir/$pnam	break      endif    end  endif  if (`echo $p|cut -c1` != "/") then    set p=`pwd`/$p  endif  set oldpath=$p restart_resolv:  set newpath="$oldpath"_  while ("$newpath" != "$oldpath")    set newpath="$oldpath"    set oldpath=`echo "$oldpath"|sed 's#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`    if ("$oldpath" != '/') then      set oldpath=`echo "$oldpath"|sed 's#/*$##g'`    endif  end  if (`echo "$oldpath"|cut -c1` == "/") then    set oldhead="/"`echo "$oldpath"|cut -c2-|sed 's#/.*$##g'`    set oldtail=`echo "$oldpath"|cut -c2-|sed 's#^[^/]*/##'`  else    set oldhead=`echo "$oldpath"|sed 's#/.*$##g'`    set oldtail=`echo "$oldpath"|sed 's#^[^/]*/##'`  endif  if ("$oldpath" == "$oldhead") set oldtail=""  while (1)    if ("$oldhead" == "") set oldhead="."    if (! -f "$oldhead" && ! -d "$oldhead") then      set newpath=""      goto getout_1    endif    set linkchar=`ls -ld "$oldhead"|cut -c1`    if ($linkchar == 'l') then      set points_to=`ls -ld "$oldhead"|sed 's#^.*->[ 	]*##g'`      if (`echo "$points_to"|cut -c1` == '/') then        set newpath="$points_to"/"$oldtail"      else        set newpath=`dirname "$oldhead"`/"$points_to"/"$oldtail"      endif      set oldpath="$newpath"      goto restart_resolv    endif    if ("$oldtail" == "") then      set oldpath="$oldhead"      break    endif    set oldhead="$oldhead"/`echo "$oldtail"|sed 's#/.*$##g'`    if (`echo "$oldtail"|grep /|wc -l` < 1) then      set oldtail=''    else      set oldtail=`echo "$oldtail"|sed 's#^[^/]*/##g'`    endif  end  set newpath="$oldpath"_  while ("$newpath" != "$oldpath")    set newpath="$oldpath"    set oldpath=`echo $oldpath|sed 's#[^/][^/]*/\.\./##g;s#[^/][^/]*/\.\.$##g;s#/\./#/#g;s#/\.$##g;s#//*#/#g;s#^\./##g;s#^/\.\./#/#g'`    if ("$oldpath" != '/') then      set oldpath=`echo "$oldpath"|sed 's#/*$##g'`    endif  end getout_1:  set p="$newpath"  set p=$p:h  setenv BACKUP_HOME $p:hendifset path=($BACKUP_HOME/bin $path)rehashunsetenv AWK# the solaris awk is doin' dawn f...... BSforeach awk (nawk gawk awk)  foreach dir ($path)    if (-x $dir/$awk) then      setenv AWK $dir/$awk      break    endif  end  if ($?AWK) breakendif (! $?AWK) then  echo 'No awk ? Is this really a lovely UNIX ?'  echo 'Sorry. I have to exit.'  exit 1endifset found=0set configfiles=($BACKUP_HOME/lib/backup.conf /etc/buclient.conf /etc/afbuclient.conf /etc/afclient.conf /etc/afbackup/client.conf "@clientconfdir@/@clientconf@")foreach configfile ($configfiles)  if (-r $configfile) then    set found=1    break  endifendif (! $found) then  echo "No configuration file found. Exiting."  exit 2endifalias getparam $AWK' '"'"'/^[ 	]*'"'"'\!:1'"'"'/{split($0,a,"'"'"'\!:1'"'"'[ 	]*"); printf "%s\n",a[2]}'"' $configfile"set SOURCEKEYFILE=`getparam '([Ee]n)?[Cc]rypti?o?n?[ 	_-]*[Kk]ey[ 	_-]*[Ff]ile:?[ 	]*'`set SOURCEKEYOPT=""if ($SOURCEKEYFILE != "") then  set SOURCEKEYOPT="-k $SOURCEKEYFILE"endifset EXITST=0set TMPFILE=/tmp/autocptape.$$/bin/rm -f $TMPFILEonintr cleanupcat > $TMPFILEset SOURCESERVER=`grep -i 'Backup Server:' $TMPFILE|awk '{print $NF}'`set SOURCEPORT=`grep -i 'Backup Port:' $TMPFILE|awk '{print $NF}'`set CARTSUSED=`grep -i 'Used Cartridges:' $TMPFILE|awk '{print $NF}'`set FIRSTFILEUSED=`grep -i 'First Tapefile accessed:' $TMPFILE|awk '{print $NF}'`set FIRSTCARTUSED=`grep -i 'First Cartridge used:' $TMPFILE|awk '{print $NF}'`set EXITSTATUS=`grep -i 'Exit status:' $TMPFILE|tail -1|awk '{print $NF}'`if ($EXITSTATUS != 0) then  set EXITST=$EXITSTATUS  goto cleanupendif/bin/rm -f $TMPFILEif (! $?TARGETSERVER) then  set TARGETSERVER="$SOURCESERVER"endifif (! $?TARGETPORT) then  set TARGETPORT=$SOURCEPORTendifset TARGETKEYOPT=""if (! $?TARGETKEYFILE) then  set TARGETKEYFILE="$SOURCEKEYFILE"endifif (! $?CARTNUMOFFSET) then  set CARTNUMOFFSET=0endifif ($TARGETKEYFILE != "") then  set TARGETKEYOPT="-k $TARGETKEYFILE"endifforeach cartrange (`echo $CARTSUSED|tr "," " "`)  set ACTCART=`echo $cartrange|cut -d- -f1`  if (`echo $cartrange|grep '[-]'|wc -l` < 1) then    set LASTCART=$ACTCART  else    set LASTCART=`echo $cartrange|cut -d- -f2`  endif  while (1)    @ TARGETCART=$ACTCART + ( $CARTNUMOFFSET )    set TAPEFILEOPT=""    if ($ACTCART == $FIRSTCARTUSED) then      set TAPEFILEOPT="-F $FIRSTFILEUSED"    endif    eval $BACKUP_HOME/bin/copy_tape -C $ACTCART $TAPEFILEOPT -h $SOURCESERVER -P $SOURCEPORT \	$SOURCEKEYOPT -D -h $TARGETSERVER -P $TARGETPORT $TARGETKEYOPT -C $TARGETCART    if ($status != 0) then      set EXITST=$status      goto cleanup    endif    if ($ACTCART == $LASTCART) then      break    endif    @ ACTCART++  endendcleanup:/bin/rm -f $TMPFILEexit $EXITSTusage:echo 'Usage: '`basename $0`' [ -k <targetkeyfile> ]' \		'[ -h <targetserver> ] [ -p <targetport> ]' \		'[ -o <cartridgeoffset> ]'exit 2

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -